Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add json object as a type for attributes in sails-mongo

Document.js

module.exports = {

  attributes: {

    type: {
        type: 'string'
    },
    createdBy: {
        model: 'User',
        required: true
    },
    body: {
        type: 'string'
    },
    comments: {
        model: 'Comments'
    },
    metaInfo: {
        type: 'json'
    }

 }

};

I would like to know if there is any way that I can write a model like the one given above, so that, I can add a json object to metaInfo which contains a name-value pair.

Eg: json: { name: 'Project', value: 'MyFirstProject'}

Is this possible through waterline?

Thanks in advance.

like image 728
DivyaMenon Avatar asked Nov 28 '14 10:11

DivyaMenon


1 Answers

I believe the comment answers your question. If you need any further help, you can refer the answers in this issue raised in Sails Github page: JSON Array of Strings

like image 197
Yedhu Krishnan Avatar answered Oct 11 '22 16:10

Yedhu Krishnan