我刚接触到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;
我需要根据用户投票单独更新投票。我可以使用钩子在同一服务中进行更新...请帮我找到答案。提前谢谢
答案 0 :(得分:3)
你想在钩子里面调用另一个服务吗?如果是,则可以在hook.app.service
中找到它们。
hook.app.service('servicename').update(...)