我用它来做一个upsert:
Articles.update(
{ title: title },
{
title: title,
parent: type
},
{ upsert: true },
function(res) {
return console.log(res);
}
);
console.log(needToGetID);
Run Code Online (Sandbox Code Playgroud)
现在我需要获取已更新或插入的文档的_id.我以为我可以通过回调得到它,但是res未定义.我假设只有一个由查询定义的唯一文档.
更新
忘记提到我正在使用流星......
我需要一些建议,以便在我的meteor-app中构建正确的角色架构和管理.
结构体
alanning:roles@1.2.13添加角色管理功能的应用程序.模块中的类别
模块的结构如下:
elementSchema = new SimpleSchema({
element: {type: String, optional: true}
});
Cars.attachSchema(new SimpleSchema({
title: { type: String },
content: { type: String },
category: { type: [elementSchema], optional: true },
});
Run Code Online (Sandbox Code Playgroud)
如您所见,所有可用类别都在模块的Collection中.
权
这就是我在技术上进行身份验证的方式:
router.js
var filters = {
authenticate: function () {
var user;
if (Meteor.loggingIn()) {
this.layout('login');
this.render('loading');
} else {
user = Meteor.user();
if (!user) {
this.layout('login');
this.render('signin');
return;
}
this.layout('Standard');
this.next();
} …Run Code Online (Sandbox Code Playgroud)