[英]In Meteor 1.3.x, how do you add a collection from within imports/api?
I have a collection of Appointments which I'm porting to the new 1.3 file structure. 我有一个约会集合,我正在移植到新的1.3文件结构。 It is structured like the Todo app, but it is still not creating the Meteor collection. 它的结构类似于Todo应用程序,但仍未创建Meteor集合。
/imports/api/appointments/appointments.js /imports/api/appointments/appointments.js
import { Meteor } from 'meteor/meteor';
import { SimpleSchema } from 'meteor/aldeed:simple-schema';
import { Mongo } from 'meteor/mongo';
export const Appointments = new Mongo.Collection('appointments');
Appointments.deny({
insert() { return true; },
update() { return true; },
remove() { return true; },
});
/imports/startup/server/index.js /imports/startup/server/index.js
import './register-api.js';
/imports/startup/server/register-api.js /imports/startup/server/register-api.js
import '../../api/appointments/methods.js';
import '../../api/appointments/appointments.js';
import '../../api/orgs/orgs.js';
Then, using "meteor mongo" and "show collections" 然后,使用“流星蒙哥”和“显示收藏集”
availability
emailvariables
invitations
meteor_accounts_loginServiceConfiguration
orgs
recurring
roles
services
system.indexes
users
What am I doing wrong? 我究竟做错了什么?
new Mongo.Collection
doesn't create a MongoDB collection automatically. new Mongo.Collection
不会自动创建MongoDB集合。 You'll need to perform an insert
to have it created. 您需要执行insert
才能创建它。 Like so: 像这样:
Meteor.startup(() => {
Appointments.insert({foo: 1});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.