mongoose Questions

6

Solved

Chatrooms.findOneAndUpdate({Roomname: room.Roomname},{ $setOnInsert: {status: true, userNum: 1}}, {new: true, upsert: true}, function(err, doc) { if(err) console.log(err); console.log("DOC " + d...
Shippen asked 27/8, 2015 at 22:36

3

Solved

Imagine I have a Mongoose model like this: mongoose = require('mongoose') Products = mongoose.model('Products') How do I get size of the full corresponding collection in bytes? I found db.collec...
Timotheus asked 2/5, 2016 at 13:35

4

after i uploaded my website on herokuy the images do not working and it gave me that error Refused to load the image '' because it violates the following Content Security Policy directive: "im...
Hartzell asked 28/2, 2021 at 2:40

11

Solved

I have a large collection of 300 question objects in a database test. I can interact with this collection easily through MongoDB's interactive shell; however, when I try to get the collection throu...
Weird asked 26/4, 2011 at 18:33

18

Solved

I've encountered a strange thing. I have several mongoose models - and in one of them (only in one!) I get this error: TypeError: Schema is not a constructor I find it very strange as I have sev...
Ob asked 27/10, 2016 at 9:20

6

Getting this error. my typescript version is 4.5.4 and "@types/mongodb": "~3.3.1", "@types/mongoose": "~5.5.17". any idea how to solve ../@types/mongodb/inde...
Hedve asked 20/2, 2023 at 17:55

7

Solved

I have this code User.findOne({ email: req.body.email }, function(err, user) { if (user) { return res.status(400).json([{ msg: 'The email address you have entered is already associated with an...
Birkett asked 25/7, 2016 at 9:3

4

Solved

I have Mongoose schema and a model: var MyClientSchema = new mongoose.Schema({ fist_name: { type: String }, phone_number: { type: String } }); var MyClient = mongoose.model('MyClient', MyCl...
Metzgar asked 12/8, 2016 at 10:0

5

Solved

When looking at tutorials there is often a delineation between a schema and a model, particularly when dealing with mongoose/mongodb. This makes porting over to postgresql somewhat confusing, as '...
Recipe asked 8/4, 2014 at 23:42

5

Solved

I'm just curious what's difference between .in() and .all() methods in mongoose Query? Can you explain by a simple example.
Eddy asked 19/8, 2012 at 15:22

4

Solved

I'm running an aggregation on a collection of around 300k+ records which requires several unwinds and regroups. I'm hitting the following error; 'exception: Exceeded memory limit for $group, but d...
Affiance asked 27/5, 2014 at 16:5

4

Solved

I want to implement method in schema class like below. import { SchemaFactory, Schema, Prop } from '@nestjs/mongoose'; import { Document } from 'mongoose'; import bcrypt from 'bcrypt'; @Schema() ...
Sitar asked 10/6, 2020 at 7:43

4

Solved

Recently I start using MongoDB with Mongoose on Nodejs. When I use Model.find method with $or condition and _id field, Mongoose does not work properly. This does not work: User.find({ $or: [ ...
Ilke asked 12/9, 2011 at 0:12

20

Solved

I am using mongoose (node), what is the best way to output id instead of _id?
Streptokinase asked 12/8, 2011 at 1:46

33

Solved

I am trying to set the test database for the testing purpose, but its not working. I am trying to connect to MongoDB using mongoose, but finding problem in the connection error shows: throw new Mon...
Cabrales asked 9/8, 2018 at 15:23

21

In my models/user.js file: var mongoose = require('mongoose'); var Schema = mongoose.Schema; var userSchema = new Schema({ (define schema) }); ... (save user) ... (check password) ... mongoose.m...
Regelation asked 30/12, 2013 at 1:29

9

Solved

The documentation here doesn't provide much of an explanation for why there are two different operations to accomplish the same thing, so I'm wondering what the differences are between them. Why mi...
Salaried asked 7/1, 2019 at 20:12

4

bI'm declaring a virtual that I want to appear as part of the results of its schema's queries, but it's not showing up when I do a console.log on the object. Here's the schema: var schema = new mo...
Tejeda asked 30/10, 2012 at 6:39

8

Solved

If you have subdocument arrays, Mongoose automatically creates ids for each one. Example: { _id: "mainId" subDocArray: [ { _id: "unwantedId", field: "value" }, { _id: "unwantedId", field:...
Soinski asked 22/6, 2013 at 18:28

2

Solved

I have a word counting function that returns an object with a set of key value pairs. Something like this: {a: 4, tale: 3, of: 8, two: 3, cities: 3 } Obviously this object can be of varying length...
Gosplan asked 13/11, 2015 at 0:35

4

Solved

I'm trying to run a simple docker setup with node and mongo: Dockerfile: FROM node:8.9.4-alpine RUN mkdir /app WORKDIR /app COPY package.json /app/ COPY package-lock.json /app/ RUN npm inst...
Paraldehyde asked 4/3, 2018 at 11:47

8

Solved

beforeAll(async () => { mongo = new MongoMemoryServer(); const mongoURI = await mongo.getConnectionString(); await mongoose.connect(mongoURI, { useNewUrlParser: true, useUnifiedTopology: t...
Termor asked 6/6, 2020 at 2:17

3

I want to populate an object into a virtual field with mongoose as a JSON object, but it always returns an array with a single item. Here is my scheme code (part with virtual field): Order.virtua...

4

Solved

I want to update a array value but i am not sure about the proper method to do it ,so for i tried following method but didnt worked for me. My model, The children field in my model childrens: {...
Decker asked 6/1, 2017 at 8:44

7

Solved

I'd like to generate a MongoDB ObjectId with Mongoose. Is there a way to access the ObjectId constructor from Mongoose? This question is about generating a new ObjectId from scratch. The generate...
Zia asked 27/7, 2013 at 16:2

© 2022 - 2024 — McMap. All rights reserved.