skip to Main Content

MongoDB aggregate merge condition

I have this below collection and I use MongoDB aggregation to acheive an output(where I aggregate all order line items for an order) and trying to merge into another collection(order). [ { "order_line_item_id": 1, "order_id": 100, "products": [ { "name":…

VIEW QUESTION

Javascript – Cannot read properties of null (reading 'collection'), this error is coming when submitting form. Unable to store data in database

in connection.js const mongoClient=require('mongodb').MongoClient const state={ db:null } module.exports.connect=function (done){ const url='mongodb://localhost:27017/' const dbname='shopping' mongoClient.connect(url,(err,data)=>{ if(err) return done(err) state.db=data.db(dbname) }) done() } module.exports.get=()=>state.db in product-helpers var db=require('../config/connection') module.exports={ addProduct:(product,callback)=>{ console.log(product) db.get().collection('product').insertOne(product).then((data)=>{ console.log(data); callback(true) }) } } I am unable to…

VIEW QUESTION

Mongodb – Prisma @unique null fails validation

I have a schema as follows: model Player { id String @id @default(auto()) @map("_id") @db.ObjectId steam_id String @unique name String level Int @default(1) elo Float @default(1500) games Game[] @relation(fields: [game_ids], references: [id]) game_ids String[] @db.ObjectId clients Client[] user User? @relation(fields:…

VIEW QUESTION
Back To Top
Search