如何使用 feathersjs 中的钩子更新 mongodb 数据?
How to update mongodb data using hook in featherjs?
我是 featherjs 的新手,我创建了一个名为 survey.this 的服务是我的数据模型
'use strict';
// surveys-model.js - A mongoose model
//
// See http://mongoosejs.com/docs/models.html
// for more of what you can do here.
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const surveysSchema = new Schema({
ownerId: { type: String},
parentId: { type: String},//Id of campaign or the community
question: String,
votes: [{
voted:[String],
answer:{type:String,enum:['answer1','answer2']}
}]
});
const surveysModel = mongoose.model('surveys', surveysSchema);
module.exports = surveysModel;
我需要根据用户投票单独更新投票..我如何使用挂钩在同一服务中进行更新...请帮我提前找到answer.thanks
是否要在挂钩内调用其他服务?如果是这样,那么它们在 hook.app.service
.
中可用
hook.app.service('servicename').update(...)
我是 featherjs 的新手,我创建了一个名为 survey.this 的服务是我的数据模型
'use strict';
// surveys-model.js - A mongoose model
//
// See http://mongoosejs.com/docs/models.html
// for more of what you can do here.
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const surveysSchema = new Schema({
ownerId: { type: String},
parentId: { type: String},//Id of campaign or the community
question: String,
votes: [{
voted:[String],
answer:{type:String,enum:['answer1','answer2']}
}]
});
const surveysModel = mongoose.model('surveys', surveysSchema);
module.exports = surveysModel;
我需要根据用户投票单独更新投票..我如何使用挂钩在同一服务中进行更新...请帮我提前找到answer.thanks
是否要在挂钩内调用其他服务?如果是这样,那么它们在 hook.app.service
.
hook.app.service('servicename').update(...)