Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sintaks MongoDB
- ambil wilayah kota
- db.wilayah.find({kode: {$regex: /^\d{2}\.\d{2}$/}}) -> 90.12
- penggunaan and
- contoh 1
- db.wilayah.find(
- {
- $and:
- [
- {
- kode:
- {
- $regex: /^32.01/
- }
- },
- {
- kode:
- {
- $regex:/^\d{2}\.\d{2}\.\d{2}\.\d{4}$/
- }
- }
- ]
- }
- ).limit(2000)
- contoh 2
- db.detail_produk_mitra.find(
- {
- $and:
- [
- { distribusi_id: "5e2a6d8b48af850035664652"},
- { produk_mitra_id: "5e2a722348af8500390ffcb5"}
- ]
- })
- .projection({})
- .sort({_id:-1})
- .limit(100)
- db.produk_mitra.find(
- {
- // produk_id: "5e04376b5f6d823f635c2822",
- // mitra_id: "5df0d671d0f4eb17823fb352"
- $and:
- [
- { produk_id: "5e04376b5f6d823f635c2822"},
- { mitra_id: "5e182f2ca24c7837187a4678"}
- ]
- })
- .projection({})
- .sort({_id:-1})
- .limit(100)
- # Users Address
- db.users_address.find(
- {
- user_id: "5ea424254c1e381d62441fde"
- // $and:
- // [
- // { kota: "36.71"},
- // { kecamatan: "36.71.04"},
- // { kelurahan: "36.71.04.1003"}
- // ]
- })
- .projection({})
- .sort({_id:-1})
- .limit(100)
- db.transaksi.find(
- {
- $and:
- [
- { mitra_id: "5e67666e42494e392720b6d4"},
- { mitra_id: {$type: "string"}}
- ]
- })
- .projection({})
- .sort({_id:-1})
- .limit(100)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement