1.0.0 • Published 5 years ago

mongowdhaha v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
5 years ago

##mongodb数据库增删改查基本操作 ####增加

  • mongowdhaha.insert(集合名,插入文档,回调)
mongowdhaha.insert('user', {name: '哈哈', pwd: '12ws'}, function (err) {
    if (err) {
        throw err;
    }
});

####删除

  • mongowdhaha.delete(集合名,删除条件,回调)
mongowdhaha.delete('user', {name: '哈哈'}, function (err) {
    if (err) {
        throw err;
    }
})

####修改

  • mongowdhaha.update(集合名,修改条件,插入的文档,回调)
mongowdhaha.update('user', {name: 'jakc'}, {name: 'jack'}, function (err) {
    if (err) {
        throw err;
    }
})

####查询全部

  • mongowdhaha.find(集合名,回调)
mongowdhaha.find('user', function (err, result) {
    if (err) {
        throw err;
    }
    console.log(result);
});

####按条件查询

  • mongowdhaha.find(集合名,查询条件,回调)
mongowdhaha.find('user', {name: '小张'}, function (err, result) {
    if (err) {
        throw err;
    }
    // 查询返回的结果集
    console.log(result);
});