mongoose的populate的使用方法

2022-05-11 22:48:23 字數 475 閱讀 7224

1 lotteryreceiverecord.find().populate("user lottery").exec(function

(err,result));

6});

78 cb(null

,result);

9 });

簡化後:

lotteryreceiverecord.find().populate("user lottery").exec(function

(err,result));

此時查詢帶有populate,查詢出的資料,引用的文件會全部打出,若是沒有populate,引用文件列印出來的都是id字串,需要列印哪一項,就將哪一項新增到populate的引數中,

注意書寫格式;若有n個引數,用空格隔開,還有其他的一些用法引數,暫時不需要,這裡就不在贅述,

mongoose的核心命令

webserver apiserver 後端工程師,前端寫介面 測試工具 postman insomina express koaexpress中乙個路由就是乙個介面 2.5.玩架構思想 需求 將express框架 rmvc框架 rmvc r router 路由 m model 資料 v view ...

mongoose使用教程

npm install mongoose const mongoose require mongoose function 下面 相當於操作圖形介面把乙個建立好的資料庫 test 開啟連線 mongoose.connection.once open err else const mongoose r...

mongoose資料校驗

一 mongoose檢驗引數 required 表示這個資料必須傳入max 用於 number 型別資料,最大值 min 用於 number 型別資料,最小值 enum 列舉型別,要求資料必須滿足列舉值 enum 0 1 2 match 增加的資料必須符合 match 正則 的規則 maxlengt...