發表文章

目前顯示的是有「mondodb」標籤的文章

[MongoDB] 如何搜尋特定開頭的資料

範例 利用 regex 搜尋 invoice_id 是 AR 開頭的 record: db.paymentRecords2.find({invoice_id:{$regex: /^AR/ }}).limit(10) 參考資料  https://stackoverflow.com/questions/53469514/mongodb-regex-string-startswith-and-endswith

[MongoDB] find 時只顯示出特定欄位 Return the Specified Fields when FIND()

範例 只顯示 name 欄位: db.counters.find({},{"name":1}).limit(50).pretty()

[MongoDB] 統計各 product_line 的資料數量 (select count(id), product_line from invoiceRequests group by product_line)

Sample: 統計各 product_line 的資料數量 db . invoiceRequests . aggregate ([ { $ group : { _id : "$ product_line ", count : { $ sum : 1 } } } ])