Bookshelfjs:不存在值的质量插入

时间:2018-06-14 12:10:08

标签: bookshelf.js

我有一组群组名称。我试图编写一个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)
        });

0 个答案:

没有答案