node-orm2
node-orm2 copied to clipboard
How do you implement the find_or_create function?
I find it difficult to implement this functionality. Has anyone done it before?
Chat.count({ id: chatId }, function(err, count) {
if (count === 0) {
Chat.create({ id: chatId }, (err) => {
console.log(err);
});
}
});
Right now I am combining count and create to create a similar method. Is there a better way to do this?