【问题标题】:How to update mongodb data using hook in featherjs?如何使用feathersjs中的钩子更新mongodb数据?
【发布时间】:2017-04-11 17:40:17
【问题描述】:

我是 featherjs 的新手,我创建了一项名为调查的服务。这是我的数据模型

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

我需要根据用户投票分别更新投票..我如何使用钩子在同一服务中进行更新...请帮助我找到答案。提前谢谢

【问题讨论】:

    标签: node.js mongodb feathersjs


    【解决方案1】:

    你想在钩子里调用另一个服务吗?如果是这样,那么它们在hook.app.service 中可用。

    hook.app.service('servicename').update(...)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-10-19
      • 2016-09-06
      • 1970-01-01
      • 2018-09-26
      • 2021-06-08
      • 2021-03-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多