Node的mongoose封裝:mongoosedao
mongoosedao = mongoose data access object
mongoosedao 是基于 node Mongoose 封裝的對 MongoDB 的 crud 等數據訪問對象,和 Java 里的 dao 比較相似,可以提高開發效率。
安裝
npm install --save mongoosedao
使用
require('./db'); var User = require('./User'); User.create({"username":"sss","password":"password"},function(err, user){ console.log(user); }); User.delete({"username":"sss","password":"password"},function(err, user){ console.log(user); });
API and Test
Test status
-
create
-
delete = remove
-
deleteAll = removeAll
-
deleteById = removeById
-
getById
-
all = getAll = find({})
-
query = getByQuery = find
-
one = findOne
-
update
-
updateOne
-
updateById
-
pageByLastId
-
top(num) && first(num) = n(num) = latest(num)
-
count(cb) &* count({},cb)
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!