1

how to findOrCreate with check data before create from relation has many on sails?

example model :

1. Thread.js

module.exports = {
    attributes: {
        name: { type: "string" },
        streams: { 
            collection: "stream",
            via: "thread"
        }
    },
    schema: true
};



2. Stream.js
  module.exports = {
        attributes: {
            title: { type: "string" },
            thread: { 
                model: "thread"
            }
        },
        schema: true
    };

how to create thread with unique streams ids, my example code :

Thread.findOrCreate({streams: {$in: ["1323","3434"] } }, {name: "me on me"});

thread can created if streams not exits on collecton has many? how do that...thank you

monoy suronoy
  • 881
  • 5
  • 10
  • 19

0 Answers0