我是featherjs的新手,我创建了一个名为survey的服务。
'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;
我需要根据用户投票单独更新投票。.我如何使用钩子在同一服务中进行更新...请帮我找到答案,提前谢谢
你想在钩子里调用另一个服务吗?如果是这样,那么它们在 hook.app.service
中可用。
hook.app.service('servicename').update(...)