[英]Can't use other Meteor packages from within other Meteor packages
我正在編寫自己的程序包,我需要依賴dburles:mongo-collection-instances
。 我知道集合實例包將修改Mongo.Collection
對象,但是我看不到在自定義包中使用Mongo.Collection.getAll()
。
var collections = Mongo.Collection.getAll(); // Doesn't work
console.log('collections', collections);
我的package.js
:
Package.onUse(function(api) {
api.versionsFrom('1.0.3.1');
api.use('jquery');
api.use('mongo');
api.use('session');
api.use('matb33:collection-hooks');
api.use('dburles:mongo-collection-instances');
api.use('accounts-base', ['client', 'server'], {weak: true});
...
});
不確定您的包裹結構如何? 我沒有使用dburles集合實例,但這是一種正確的結構方式:
/packagefolder
both.js
package.js
在你的package.js
Package.describe({
summary: 'mycollection collection',
name: 'mycollection:mycollection',
version: '0.0.1'
});
Package.onUse(function (api) {
api.use('jquery');
api.use('mongo');
api.use('session');
api.use('matb33:collection-hooks');
api.use('dburles:mongo-collection-instances');
api.use('accounts-base', ['client', 'server'], {weak: true});
api.addFiles([
'both.js'
], ['server', 'client']);
api.export('MyCollection');
});
我推薦aldeed收集包..這是一個both.js
演示
MyCollection = new Mongo.Collection('mycollection');
Schemas = {};
Schemas.MyCollection = new SimpleSchema({
profileId: {
type: String
},
date: {
type: Date
}
});
MyCollection.attachSchema(Schemas.MyCollection);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.