mongoose Questions
3
Solved
When I am trying to Save/Create a New Document (User) to Mongo DB using Mongoose, I am getting the following Validation Error in spite of providing all the Values with proper DataType:
ValidationE...
3
Solved
I need to update my model when the data has changed. Sadly, this seems to not work.
const mongoose = require('mongoose');
const moment = require('moment');
const Schema = mongoose.Schema;
const So...
4
I'm trying to have an "optional" nested document in one of my models. Here's a sample schema
var ThingSchema = mongoose.Schema({
name: String,
info: {
'date' : { type: Date },
'code' : { type...
6
Solved
I am having an issue which I tried to fix for a long time.
I am trying to connect to Mongo Atlas cloud from nodejs viamongoose.
It's not my first time but I just can't find the answer.
Mongoose ver...
5
I have a collection on MongoDB from which I'm trying to query all the elements using find():
const mongoose = require('mongoose');
const Featured = mongoose.model('featured');
module.exports = app ...
Onieonion asked 23/12, 2020 at 2:22
4
I am aware of how to set up a one to many relationship between Mongoose entities, with the following type of code :
friends: [{type: ObjectId, ref: 'User'}]
But what if I want to only have a on...
10
Solved
Mongoose adds a '__v' property into Schema's for versioning - is it possible to disable this globally or globally hide it from all queries?
Coronal asked 4/12, 2012 at 9:34
9
Solved
I have created a new Mongo collection to a new project, but when I try to create a new user, I get the following error:
MongoError: E11000 duplicate key error collection: GestorMedico.users index: ...
Buhr asked 17/1, 2022 at 9:32
5
Solved
My code is like that:
SiteModel.find(
{},
function(docs) {
next(null, { data: docs });
}
);
but it never returns anything... but if I specify something in the {} then there is one record. so...
2
Solved
I have the following schema with mongoose:
var SimSchema = new Schema({
msisdn : { type : String , unique : true, required : true },
imsi : { type : String , unique : true, required : true },
s...
6
Solved
I am new to Node.js and am trying to build a node/express/mongoose server app with TypeScript.
Here is my app.ts file:
// lib/app.ts
import express from 'express';
import * as bodyParser from 'bo...
Nyctophobia asked 15/9, 2019 at 13:54
11
Solved
Is it possible to query for a specific date ?
I found in the mongo Cookbook that we can do it for a range Querying for a Date Range
Like that :
db.posts.find({"created_on": {"$gte": start, "$lt":...
6
Solved
so, I've been working with mongoose for some time and I found some really weird stuff going on. It would be great if someone could enlighten me.
The thing is, when using the .find() method of mong...
Anthem asked 10/2, 2015 at 22:14
4
Hi i want save with hashed password only if password is change, so i used isModified function in pre-save, but its always return false even i changed the password. The reason that i am trying to do...
5
I have the following document schema:
var pageSchema = new Schema({
name: String
, desc: String
, url: String
})
Now, in my application I would like to also have the html source of the page i...
12
getting ReplicaSetNoPrimary and MongoServerSelectionError error while connecting MongoDB with nodejs
I am trying to connect to mongodb but getting below error could you please help
var mongo = require('mongodb').MongoClient;
mongo.connect('mongodb://usernamexyz:[email protected]:47017/sample...
Gurgitation asked 4/2, 2020 at 18:50
51
Solved
Not Sure what I'm doing wrong, here is my check.js
var db = mongoose.createConnection('localhost', 'event-db');
db.on('error', console.error.bind(console, 'connection error:'));
var a1= db.once('...
3
Solved
I'm searching on Google since days and I tried many things but I still can not perform a good full text search on my user collection.
I tried ElasticSearch but was pretty impossible to query and p...
Barrie asked 27/2, 2015 at 21:59
3
Solved
I want to test if "upsert" option for updating is woking fine. So I "upsert" an object into mongodb twice with same key. However it didn't show inserted message. Was I missing something ?
(mongodb...
Marje asked 3/11, 2014 at 5:0
5
I'd like to create a Mongoose Schema that validates the object below with the following restrictions:
field2 is optional (0-1 relationship),
field2.type is required if field2 exists (notice that ...
2
Solved
I have an app that works on node.js with MongoDB and mongoose. My app simply sends/deletes/edits form data and for that, I have such mongoose model:
var mongoose = require('mongoose');
module.exp...
6
Solved
I'm creating a mongoose Schema but I'm getting a MongooseError.
This is my Scheme:
let RestaurantSchema = new Schema({
ratings: {
type: [{
id: Number,
value: Number,
_id: false
}],
default...
4
When using vanilla Mongoose, it's straight-forward to add methods to Mongoose schemas. It's well-addressed by the Mongoose documentation and several examples can be found.
But what about when you'r...
Tanyatanzania asked 22/2, 2021 at 16:1
6
I'm querying Mongo in Nodejs with Mongoose and attempting to extract the numeric value of multiple fields stored as a Decimal128. However, the value is oddly wrapped in query results and I'm not su...
Jakie asked 19/11, 2018 at 6:56
3
I think that it was easy question, but I am puzzled.
How Can I add minimum value to mongoose > 0?
var customer = new Schema({
cash: {
type: Number,
minimum: 0
}
});
this code allow 0 value, ...
© 2022 - 2024 — McMap. All rights reserved.