skip to Main Content

Mongodb – How to accumulate category counted fixed-size array in `$group` stage?

Let books collection be, db.books.insertMany([ { "name": "foo", "category": 0, publishedAt: ISODate("2008-09-14T00:00:00Z") }, { "name": "bar", "category": 1, publishedAt: ISODate("1945-08-17T00:00:00Z") }, { "name": "baz", "category": 1, publishedAt: ISODate("2002-03-01T00:00:00Z") }, { "name": "qux", "category": 2, publishedAt: ISODate("2002-01-21T00:00:00Z") }, { "name": "quux",…

VIEW QUESTION

Mongodb – okhttp not sending header on post request

I am trying to send a simple post request to MongoDB using okhttp. Here is the code that I am working with: try { String jsonStr = om.writeValueAsString(postRequest); RequestBody body = RequestBody.create( jsonStr, MediaType.parse("application/json; charset=utf-8")); // also attempted with MediaType.parse("application/json")…

VIEW QUESTION

Mongodb – how to solve the error MongoServerError: E11000 duplicate key error collection: test.admins index: status_1 dup key: { status: "true" }

here is my shcema file. name:{type:String,unique:true,required:true}, email:{type:String,unique:true,required:true}, userName:{type:String,unique:true,required:true}, password:{type:String,unique:true,required:true}, status:{type:String,unique:true,default:true} },{timestamps:true}) And i'm converting the password in to bcrypt

VIEW QUESTION
Back To Top
Search