Mongodb – mongoose search text in nested object
there is a nested mongodb document that looks like the image below. I want to do a search in the body field in this document, but I could not succeed. how can i do this search. thanks in advance I…
there is a nested mongodb document that looks like the image below. I want to do a search in the body field in this document, but I could not succeed. how can i do this search. thanks in advance I…
I want to query a collection "chat" whose documents have an array field "participants". This array has always two objects with the properties id and name. I want to find the document that matches the two ids of the embeded…
I am working on a node js project where I am getting the following error : CastError: Cast to ObjectId failed for value "[ [ '63e8e6e8b8a285d68b1fbd0c', '63e9951ded54221a516fc622' ] ]" (type Array) at path "labels" because of "BSONTypeError" at ObjectId.cast (/var/www/html/IssueTracker/node_modules/mongoose/lib/schema/objectid.js:248:11)…
As for now, I'm using mongoose middleware to handle Mongoose specific errors (validation, cast, ....). I'm using the following code in all of my schemas: schema.post('save', handleValidationError); schema.post('findOneAndUpdate', handleValidationError); schema.post(['findOne', 'deleteOne'], handleCastError); Is there anyway to make this global in…
I have this simple collection of students: { "_id": "btv7865reVGlksabv", "students": [ { "name": "John", "age": 30 }, { "name": "Henry", "age": 25 } ] } Now I want to push new students into this array: const newStudents = […
I have this document: Now I want to add a new key / value to that document which id is : 34401 My key / value is like an array: $data = [ 'id_project' => $id_project, 'id_product' => $product_id, 'link'…
when i run the code, the server server side receive the message but the client side doesnt get anything until they send message. however in html doesnt show anything wrong i have this server code: var http = require('http').Server(app); var…
I am using Mongo to store multi tenant data. As part of data cleanup for a tenant I want to delete everything related to the tenant. The tenantId is indexed but there are alot of rows and it takes a…
Context : I'm trying to build an architecture displaying POIs which can be at different know locations over time. I have 2 collections, pois { _id: ObjectId, name: string } locations _id: ObjectId, point: { type: 'Point', coordinates: Array<number> },…
I am using this package for my Laravel Application. I can get single collection data using this query: $product = DB::connection( 'mongodb' )->collection( 'products_1' )->paginate( 5 ); Now, I have multiple collection for e.g: products_2, products_3, products_4 and so on...…