Posts by jcardoso • 171 points
16 posts
-
0
votes1
answer62
viewsA: findByIdAndUpdate() is creating document instead of updating
I even did a test here. was normal. could be the id if it is not in the schema it does not consider. I used _id var mongoose = require('mongoose'); const { Types } = mongoose; // "mongoose":…
-
0
votes1
answer278
viewsA: Mongodb - Add documents that have a certain value within an array
I hope it helps.. var parking_id = '5d752c544f4f1c0f1c93eb23'; db.parking.aggregate([ { $match: { '_id': parking_id } }, { $project:{ parkingTotal:{ $sum:{$map:{ input:'$parkingSpace', as: 'p', in:{…
-
2
votes1
answer459
viewsA: How to group data into an array, making a single object | MONGO + NODE
manual/pipeline referral I hope it helps what I’ve done: db.people.aggregate([{ $lookup: { from: 'wallets', let: { walletsID: '$_id' }, pipeline: [ { $match: { $expr: { $in: [ '$$walletsID',…
-
0
votes1
answer101
viewsA: Aggregation with Mongodb and $lookup
This Right however you are saving the "serveropcid" as a string and not as Objectid. If using mongoosejs set in schema. Behold:Lookup with pipeline Your Object from Collection groupocoletors should…
-
4
votes1
answer193
viewsA: Bingo - Javascript
var sorteio = document.querySelector('p#numSorteio') var sortNum = sorteio.innerHTML var numAleatorio document.getElementById("mylink").onclick = gerarAleatorio = () =>{ numAleatorio =…
javascriptanswered jcardoso 171 -
0
votes2
answers68
viewsA: Mongodb Agregation + Lookup
As Eduardo Klein wrote " 'markets', and take the Ids (Eans) of products" I hope it helps. db.mercados.aggregate([ { $unwind: { 'path': '$produtos', 'preserveNullAndEmptyArrays': true }}, { $lookup:…
-
0
votes2
answers61
viewsA: Mongodb not installed
No, as long as you do not delete the folder that is configured: Where and how to store data. Storage: dbPath: /var/lib/mongodb I did it to get from 3.2 => 4.0…
-
0
votes3
answers63
viewsA: How to specify a maximum of digits in a var in Javascript
Voce can do so: parseFloat('39.576911261669586').toFixed(2)
-
1
votes1
answer83
viewsA: Change document after post-save middleware in Mongoose
Voce can try to do a pre update at the end of your document: FooSchema.pre('update', function() { this.update({ _id: this._id},{$set: { bar:'bar'} }); }); hope it helps.…
-
0
votes1
answer157
viewsA: How do I search different mongodb documents and subdocuments
From what I saw in the example the _id does not have a link: If you have a bond you can make one lookup in Collection Usuario in place in the project, I did on top of the result you put as an…
-
2
votes2
answers1634
viewsA: Image is not displayed when listed on Node Js
Voce does not need to put . /public/images/ since the public folder is already defined. try <img src="images/<%= lista[i].imagem %>" height="42" width="42">
-
-1
votes1
answer771
viewsA: Mongodb queries using like and disregarding accents and case
Voce can use regex to search: db.getCollection('pessoas').find({ nome: { $in: [ /^Jos/i, /^é/ ] } } )
-
-1
votes1
answer34
viewsA: Two query operations on a Collection
Voce can use : db.collection.findOneAndUpdate retira.findOneAndUpdate({age: 17}, {$set:{name:"Naomi"}}, {new: true}, function(err, doc){ if(err){ console.log("Something wrong when updating data!");…
-
0
votes1
answer57
viewsA: Remove all result Aggregate mongodb array
How I solved the problem I hope you help someone. "feriados": { $let: { vars: { varin:{ $map: { input: db.feriados.distinct('data', { 'status': true }), as: 'feriado', in: { "$not": [{…
-
1
votes1
answer57
viewsQ: Remove all result Aggregate mongodb array
I have the following total array I need to get only those that have date. { "_id" : ObjectId("58862a838f3e2721f8d920cc"), "total" : [ [], [], [ ISODate("2017-09-07T00:00:00.000Z") ], [], [], [], []…
-
0
votes1
answer160
viewsA: Aggregate and lookup in subdocuments
I hope it helps. see that you expect to have a reference to the Collections objectId db.alunos.aggregate([ { $unwind: "$provas" }, { $unwind: "$provas.questoes" }, { $lookup: { from: "questaos",…