在NETCONF中使用远程过程调用(use of remote procedure call in NETCONF)
我正在阅读有关netconf的RFC6241,其中有关于RPC作为协议的消息传递机制的说法。 但是,规范定义了用于传输RPC消息的XML,所以我不太明白为什么这仍然被称为RPC? 我曾经认为在ONC RPC中描述了RPC ,即应该定义一个存根函数(由Unix上的rpcgen完成)等等,但NETCONF所说的并不严格遵循这个范例,而是定义了一种传输机制电线参数。
也许,我误解了RPC作为一个概念。 有人可以为我澄清netconf中的RPC吗? 谢谢,
I was reading RFC6241 about netconf, where it's said about RPC as a messaging mechanism of the protocol. However, the spec defines XML for transmitting RPC messages, so I don't quite understand why this is still called RPC? I used to think of RPC as described in ONC RPC, i.e. there should be a stub function defined (as done by rpcgen on Unix) and so on, but what NETCONF says does not strictly follow this paradigm, rather it defines a mechanism to transmit parameters over wire.
Perhaps, I misunderstand RPC as a concept. Could anybody clarify RPC in netconf for me? Thanks,
原文:https://stackoverflow.com/questions/34276899
最满意答案
教师发现功能将被异步调用,所以JavaScript代码将继续之前,你有该猫鼬查询的结果。
您需要在回调中添加课程的保存。 可能看起来像这样:
if (!req.body) return console.log("No data sent"); dbs.collection('instructors').find({ name: req.body.iname }).toArray((err, instructors) => { if (!err) { if (!instructors) { var newcourse = new clist({ // new data also from instructors }); newcourse.save(function(err) { if (err) { res.status(400); res.send(err); } else { res.status(200); res.redirect('/course'); } }); } else { res.status(400); res.send("Could not find instructor"); } } else { res.status(400); res.send(err); } });
但请注意,通过这种方式,您可以获得具有给定名称的所有教师,并且您必须从该阵列中选择一个。 如果您想要将更多课程保存到教师中,则必须更改模式:例如
var courseSchema = mongoose.Schema({ // Schema variables ... }); var courseModel = mongoose.model("Course", courseSchema); var instructorlist = mongoose.Schema({ name: { type: String, required: true }, ... courses: [{ type: ObjectId, ref: "Course" }] });
The instructors find function will be called asynchronously so the javascript code will go on before you have the results of that mongoose query.
You need to add the saving of the course inside the callback. Could look like this:
if (!req.body) return console.log("No data sent"); dbs.collection('instructors').find({ name: req.body.iname }).toArray((err, instructors) => { if (!err) { if (!instructors) { var newcourse = new clist({ // new data also from instructors }); newcourse.save(function(err) { if (err) { res.status(400); res.send(err); } else { res.status(200); res.redirect('/course'); } }); } else { res.status(400); res.send("Could not find instructor"); } } else { res.status(400); res.send(err); } });
But be aware that with this you get all instructors with the given name and you have to select one from that array. If you want to save more courses to a instructor you have to change the schema: e.g.
var courseSchema = mongoose.Schema({ // Schema variables ... }); var courseModel = mongoose.model("Course", courseSchema); var instructorlist = mongoose.Schema({ name: { type: String, required: true }, ... courses: [{ type: ObjectId, ref: "Course" }] });
相关问答
更多-
LINUX 如何查看JPG文件[2022-06-13]
find -
Mongodb本身不支持连接。 所以,猫鼬填充是对外部参考分辨率的尝试。 与mongodb的事情是,你需要设计你的数据,以便: 大多数查询不需要引用多个集合。 从查询中获取数据后,您不需要将其转换太多。 考虑所涉及的实体及其关系: 品牌就是品牌。 不依赖于其他任何东西。 每个产品都属于一个品牌。 每个产品都与样式相关联。 每个帖子都与一个产品相关联。 间接地,每个帖子都通过产品与品牌和风格相关联。 现在介绍一下用例: 请参阅:如果您正在通过ID查找一个实体,那么提取1-2个相关实体并不是很大的开销。 列表: ...
-
数据没有填充在猫鼬中(Data not populating in mongoose)[2023-03-09]
你不能在mongoose中填充嵌入字段,但你可以使用一些解决方法 1)将您的相关数据保存在其他字段中 var employee = { grd: {type: mongoose.Schema.ObjectId, ref: 'grade'}, grdData: { grade: [], effFrom: {type: Date, default: Date.now}, effTo: {type: Date} } }; 2)使用像mong ... -
您需要为静态函数使用正常函数声明,而不是使用胖箭头语法,以便在函数中保留Mongoose的含义: schema.statics.getUserByToken = function(token, cb) { return this.find({ examplefield: token }, cb); }; You need to use a normal function declaration for your static function instead of using the fat-ar ...
-
这个问题肯定需要更多的细节,但如果我们假设显示的findOne代码有效,但未显示的find代码没有,那么这可能是由于返回值没有正确地用于find代码。 缺少find代码的假设: Member.find().exec((err, member) => { res.json(member.toAuthJSON()) }); 同样,如果这个假设是正确的,那么它就是对find返回值的误解。 findOne将返回单个文档, find返回文档数组 。 因此,假定的代码需要更新以迭代返回的数组,调用每个文档的自定义 ...
-
您正在运行错误的过滤器来查找文档。 {'a': '1', 'b' : '2', 'c': '3'} 问题出在你的模型对象中,你将b定义为key1的其他属性的属性, c定义为key1.key2.c属性,以及与x相同的属性。 { a: req.body.a, key1:{ b: req.body.b, key2: { c: req. ...
-
从Mongoose find方法中的其他集合中获取数据(fetching data from other collections inside Mongoose find method)[2023-05-05]
从本质上讲,问题不在于猫鼬而是mongo。 你要做的是基本上在非关系数据库中拉关系数据。 根据经验,我建议不要这样做。 如果你无法避免,请使用postgres。 Postgres支持json数据。 在mongoose中,您可以使用.populate方法加载第一级关系(用户 - >帖子)。 如果你想引入二级关系(用户 - >帖子 - >回复),那么你最终需要在代码中手动创建联接。 因此,如果用户有多本书,您可以像这样设置您的模式。 User = new mongoose.Schema({ // ... -
没有架构的猫鼬(Mongoose without schema)[2022-11-13]
Mongoose说您可以使用Mixed模式来定义无模式类型。 权衡的是,如果在调用save之前修改了Mixed Schema值,则必须告诉mongoose。 除此之外,您应该能够在“架构”中定义任何您想要的内容。 文档 - http://mongoosejs.com/docs/schematypes.html#mixed Mongoose says that you can use a Mixed schema to define a schema-less type. The trade off is t ... -
我做了这些更改来解决问题: 我没有在mongo shell中创建集合,而是将以下代码放在module.factory.js this.Person = mongoose.model('Person',PersonSchema); this.Person.db.collection("user", { .... } ); I did these changes to solve the issue: Instead of creating collection in mongo shell, I put t ...
-
var contactdetails1 = new db.Schema({ name:req.body.name, email:req.body.email, password:'', number:req.body.number }); 你应该保存一个模型,而不是模式。 你在这里完成的是将一个对象传递给模式。 文档是模型的实例,而不是模式。 模式只是一个对象定义。 而不是你在这里所做的,你为什么不做 var ContactModel = mongoose.model('Contactde ...