skip to Main Content

Get an element from an array of objects with an id in mongodb using nodejs and mongoose

I've a many documents like this user:62e13ae4f9a38f7610e70bd7, _id :62e13ae4f9a38f7610e70bdb transactions:{ { "amount": 50, "category": "Bills", "type": "Expense", "date": "2022-01-20T00:00:00.000Z", "_id": "62e13ae4f9a38f7610e70be0" }, { "amount": 100, "category": "Lottery", "type": "Income", "date": "2022-01-20T00:00:00.000Z", "_id": "62e13ae4f9a38f7610e70be1" }, { "amount": 200, "category": "Salary", "type":…

VIEW QUESTION

mongodb query filter documents by array value or size

I have a document that's look like this if it hasn't got any items in the itemList field: { "_id":{ "$oid":"62e12a0b73a8c3469e635d93" }, "listName":"name of list", "alloweUidList":[ { "uid":"prQUKkIxljVqbHlCKah7T1Rh7l22", "role":"creator", "boolId": 1, } ], "itemList":[ ], "crDate":"2022-07-27 14:05", "modDate":"2022-07-27 14:05", "boolId":1…

VIEW QUESTION

What is MongoDB aggregate pipeline?

Using Mongoose driver Consider the following code : Connecting to database const mongoose = require("mongoose"); require("dotenv").config(); mongoose.connect(process.env.DB); const userSchema = new mongoose.Schema({ name: String }, {collection: 'test'}); const Model = mongoose.model('test', userSchema); Creating dummy document async function createDocs() { await…

VIEW QUESTION
Back To Top
Search