insert to MongoDB array with axios, restAPI and nodeJS
I am trying to add an item to a MongoDB array with RESTAPI through Axios. I thought it would look similar to the push method but I have no idea how to do that. my Model is of a person:…
I am trying to add an item to a MongoDB array with RESTAPI through Axios. I thought it would look similar to the push method but I have no idea how to do that. my Model is of a person:…
I just connected mongoDB using mongoose. But I got error TypeError: Cannot read properties of undefined (reading 'split') How can I fix this error? Here's my code export const dbConnect = async () => { mongoose.connect(process.env.NEXT_PUBLIC_MONGO_URI); const db = mongoose.connection;…
I have the below dbData wherein in the contracts collection, there is an attribute called via which is an array that holds the mongoose ids of depot entries. db={ "contracts": [ { "_id": ObjectId("630c9e23fb146c4b3b801b9e"), "detention_id": [], "route_exclude": false, "trip_count": null,…
{ "id": 1, "holdDetails": [ { "holdDescription": "COVERT_LOCK", "holdStatus": "CREATED" }, { "holdDescription": "ALPH_LOCK", "holdStatus": "RESOLVED" } ] }, { "id": 2, "holdDetails": [ { "holdDescription": "ALPHA_LOCK", "holdStatus": "RESOLVED" }, { "holdDescription": "BETA_LOCK", "holdStatus": "RESOLVED" } ] }, { "id":…
I'm learning mongoDB queries and have a problem given my collection looks like: "filename": "myfile.png", "updatedCoordinates": [ { "xmin": 537.640869140625, "xmax": 1049.36376953125, "ymin": 204.90736389160156, "ymax": 714.813720703125, "label": "LABEL_0", "status": "UNCHANGED" }, { "xmin": 76.68355560302734, "xmax": 544.8860473632812, "ymin": 151.90313720703125, "ymax": 807.1371459960938,…
I am new to react and MongoDB, I have this site where the user can log in and look at his detail like nameā¦, coming from the db. I am trying to find a way to update what is shown…
I have the following data structure: { "_id": ObjectId("630bd746956bba0f6f0ba448"), "a": [ { "b": [ [ [ { "c": "aaa" } ] ] ] } ], } How can I filter all documents with the value aaa for their nested c…
I am trying to query a user by their name field, and I am testing it in insomnia. I have my user schema like so: const userSchema = mongoose.Schema({ id: { type: String }, name: { type: String, required: true,…
here I am trying to insert an object to Mongodb via POST using axios.the object that I send gets successfully inserted in the MongoDB collections. after inserting the object I need to redirect to the home page but instead of…
import express from 'express'; import bodyParser from 'body-parser'; import mongoose from 'mongoose'; import cors from 'cors'; const app = express(); app.use(bodyParser.json({limit: "30mb", extended: true})); app.use(bodyParser.urlencoded({limit: "30mb", extended: true })); app.use(cors()); const CONNECTION_URL = 'mongodb+srv://humoudmajid:[email protected]/?retryWrites=true&w=majority' const PORT = process.env.PORT || 5000;…