2017-04-09 1 views
0

Iamはfeatherjsする新しいと私はsurvey.this呼ばつのサービスを作成したがfeatherjsでフックを使ってmongodbデータを更新するには?私は、同じサービスで更新を行うことができますvoting..howユーザーに応じて個別に票を更新する必要が

'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; 

私のデータモデルですフックを使用して...私は答えを見つけるのを助けてください。おめでとうございます。

答えて

3

フックの中で別のサービスを呼び出したいですか?その場合は、hook.app.serviceにあります。

hook.app.service('servicename').update(...) 
関連する問題