2017-10-25 1 views
1

In Meteor-Projekt muss ich in diesem Beispiel {Meteor}, {Mongo} und {check} importieren? Warum?Erforderliche Importe für Meteor

collections.js

// import {Mongo} from 'meteor/mongo' // ---- i have to import this? 

    Bookmarks = new Mongo.Collection('bookmarks') 

methods.js

// import {check} from 'meteor/check' // ---- i have to import this? 
    import {Bookmarks} from "/imports/schema/bookmarks/index" 

    Meteor.methods({ 
    'bookmark.add'({name, url}){ 
     check(name,String) // --------------- 
     check(url,String) 

    const bookmarkId = Bookmarks.insert({name,url}) 
    Meteor.isServer && console.log(`Id ${bookmarkId} inserted`) 
    }, 
    'bookmark.remove'(_id){ 
    check(_id,String) 

    const bookmark = Bookmarks.findOne({_id}) 
    if (!bookmark){ 
     Meteor.isServer && console.log('no such a bookmark!') 
    } else { 
     const removeBookmarkId = Bookmarks.remove({_id}) 
     Meteor.isServer && console.log(`remove result ${removeBookmarkId?'success':'error'}`) 
    } 
    } 
}) 

Antwort

2

Die kurze Antwort ist ja . Meteor nutzt das Modulsystem für Im- und Exporte intensiv. Sie können mehr darüber lesen, wie Meteor Module funktioniert, und die Gründe, die den Umzug zu Meteor-Modulen here motivieren.

Verwandte Themen