Sunday, 9 April 2017

How to update mongodb data using hook in featherjs?

Iam new to featherjs and i created one service called survey.this is my data model

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

i need to update the votes seperately according to the users voting..how i can do the update in the same service using the hook...please anybody help me to find the answer.thanks in advance



via MonuKJ33

No comments:

Post a Comment