【发布时间】:2016-04-22 16:39:56
【问题描述】:
我正在尝试对具有 google 和默认帐户登录的流星 crud 操作示例做出反应。用户登录显示为自己的记录。
createContainer 函数将联系人返回为[ ],为什么?
首先我尝试使用谷歌帐户登录,它工作正常。之后,我添加了流星帐户 ui 和帐户密码。然后它给了我空联系人。所以这里必须缺少一些东西才能使用流星帐户 ui。
这是我所做的。
list.jsx
export default createContainer(() => {
return {
contacts: Contact.find({}).fetch(),
user: Meteor.user(),
};
}, ContactList);
我的架构:-
export const Contact = new Mongo.Collection('contact');
Meteor.methods({
'contacts.insert'(firstName,lastName,email,password){
if (!Meteor.userId()) {
throw new Meteor.Error('not-authorized');
}
ContactSchema = new SimpleSchema({
"firstName": {
type: String
},
"lastName": {
type: String
},
"email": {
type: String,
regEx: SimpleSchema.RegEx.Email,
label: "E-mail address"
},
"password": {
type: String,
min:6,
label:'password at least 6 character'
},
"owner": {type: String},
"createdAt": {type: Date}
});
Contact.insert({
firstName,
lastName,
email,
password,
createdAt: new Date(),
owner: Meteor.userId()
});
Contact.attachSchema(ContactSchema);
},
【问题讨论】: