我有一组群组名称。我试图编写一个Bookshelf语句,将数组与组表进行比较,如果它们不是大量存在则插入新组。我该怎么做呢?
这是我的阵列:
const tagsToAdd = req.body.tagsToAdd;
我尝试做的事情是这样的:
Group.model()
.query()
.whereNotIn('name', tagsToAdd) //this is wrong-I need the opposite of this,
//in other words, a list
// of the members of tagsToAdd which have no corresponding entries in the table
.batchInsert('endpoint_group', tagsToAdd, 1000)
.then(function(response){
console.log(response)
})
.catch(function(e){
console.log('error: ', e)
});