简体   繁体   English

如何使用Mongo在Express中传递对象元素?

[英]How do I pass an object element in express using Mongo?

I want to pass a whole object from an ejs template 我想从ejs模板传递整个对象

For example: 例如:

var schema = ... { Name: [{ var schema = ... {名称:[{

}] } }]}

With this you can achieve it, hope that's what you ask... 有了这个,您就可以实现,希望这就是您要的...

  notifications: {
    notifiId: {type: Schema.Types.ObjectId, ref: 'Notifications' },
    viewed: { type: Number, default: 0 }
  },

and to find it: 并找到它:

model_Variable.findById(req.params.id).populate("notifiId").exec(function (err, 
callBack) {});

Source: How to populate in this case Mongoose 资料来源: 如何在这种情况下填充猫鼬

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用Express将数据传递到不同的路由? - How do I pass data to different routes using Express? 如何使用Express和Mongo制作一个简单的GET和POST表格? - How do I make a simple form GET and POST using Express and Mongo? 如何使用 express 切换 JSON object 中的 boolean 值? - How do I toggle boolean values in JSON object using express? 如何使用express访问get请求的结果(对象)? - how do I access the result(object) of a get request using express? 使用 Mongo/Mongoose/NodeJS/Express 删除元素会破坏我的应用程序并发送带有空对象的错误 - Deleting an element breaks my app and sends an error with an empty object, using Mongo/Mongoose/NodeJS/Express 如何使用express-handlbars将数据对象传递到视图? - How do I pass a data object to my view with express-handlbars? 如何将 mongo 查询的返回值传递给表达模板 - How can I pass the return value from mongo query to express template 我如何在nodejs中与我的主应用程序在同一端口上设置Mongo查看器(如Mongo-Express)? - How do I, in nodejs, set up a Mongo viewer (like Mongo-Express) on the same port as my main app? 如何在Express中的路线之间传递变量? - How do I pass a variable between routes in express? 如何将模板中的内容传递到Express中的布局? - How do I pass content from a template to a layout in Express?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM