mongoose Questions
4
I've encountered a problem while setting up mongoose.
Here is my code:
const { SlashCommandBuilder } = require('@discordjs/builders');
const testSchema = require(`../../Schemas.js/test`);
module.e...
Langue asked 6/3, 2023 at 9:52
3
Solved
I have a simple user model:
{
_id: "59d72070d9d03b28934b972b"
firstName: "first"
lastName: "last"
email: "[email protected]"
subscriptions: {
newsletter: true,
blog: true
}
}
I'm tr...
Maharajah asked 7/10, 2017 at 9:51
9
Solved
I just started learning Node.js. The idea of this small application is to use express and mongosse to store some users in a based cloud database (mongoDB via mlab).
I have two seperate files :
Us...
8
Solved
I'm creating a new user and checking whether the user email previously exists or not. If not then it is creating a new user and saving it. What do I need to correct this validation error I am getti...
2
By default mongoose/mongo will populate a path using the _id field, and by it seems like there is no way to change the _id to something else.
Here are my two models which are connected with one-to...
Greenhorn asked 7/4, 2020 at 20:42
17
Solved
Below is my code
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/test');
var Cat = mongoose.model('Cat', {
name: String,
age: {type: Number, default: 20},
create: {ty...
9
Trying to model a relationship between collections by embedding documents
but when validating in the schema and setting "required" to True, here comes the err
once I comment the required in genre ...
Leaves asked 29/5, 2019 at 7:36
12
Solved
Is there a function to turn a string into an objectId in node using mongoose? The schema specifies that something is an ObjectId, but when it is saved from a string, mongo tells me it is still just...
12
I updated Mongoose to the latest version (6.0.1) and now I'm getting this error whenever .findOne() is executed:
MongooseError: Query was already executed: Streams.findOne({ i: 6 })
at model.Query...
2
Solved
For hashing a password before the object is saved to mongodb, i use the built-in pre-save hook comming with mongoose.
But what is the correct way to handle hashing during updates?
I tried to solv...
8
Solved
when I run my app with npm run seeder
then I have face this error
I have checked my database connection carefully, it's ok.
also, I have checked my ordermodels file it's also ok. I have used MongoD...
9
Solved
I have a nest.js node server and I am trying to connect mongoDB data base in the app.module, when the connection string doesn't contains the DB name - the connection to default DB "test" ...
4
Solved
Can I define a schema in mongodb which requires certain attributes to be set. Much like NOT NULL in SQL. If that is possible. What is the syntax for this?
I am using node.js and mongoose.
mongoose...
3
Solved
I have a request which body contains data and _id
What is the better way to implement code that will update if record with _id exists and will create one is there is no one? My code:
var obj = re...
Mistress asked 12/11, 2012 at 2:37
2
The number is larger than 9223372036854775807 - too big for NumberLong, which is mongo's native 64-bit long type. What's the best way to do this/the best field type?
Is it possible to preserve an...
Amourpropre asked 30/3, 2017 at 22:56
3
I am using mongoose to connect to my Mongodb Atlas cluster through my nodejs server.
There is a certain operation which is done as a transaction. Mongoose needs mongoose.startSession() to be calle...
4
Solved
I am using Mongoose to access to my database. I need to use transactions to make an atomic insert-update.
95% of the time my transaction works fine, but 5% of the time an error is showing :
"Give...
Abruzzi asked 21/10, 2019 at 14:4
4
I have a Mongo collection of Users and a collection of Addresses. Each address is owned by one user.Here are my schema classes:
export type UserDocument = User & mongoose.Document
@Schema({ ti...
Esme asked 27/2, 2021 at 2:35
18
Solved
According to this mongodb article it is possible to auto increment a field and I would like the use the counters collection way.
The problem with that example is that I don't have thousands of peo...
Novgorod asked 6/2, 2015 at 3:11
10
Solved
I have a node.js application that pulls some data and sticks it into an object, like this:
var results = new Object();
User.findOne(query, function(err, u) {
results.userId = u._id;
}
When I d...
3
Solved
I have an issue I've not seen before with the Mongoose findByIdAndUpdate not returning the correct model in the callback.
Here's the code:
var id = args._id;
var updateObj = {updatedDate: Date....
0
I need to get a way of implementing vector search on text , image and
video attributes which are stored as document in Mongodb. I am using
mongoose node package for model file for node js applicat...
3
Solved
When I try to use MongooseModel on Users I am getting the following error
Nest can't resolve dependencies of the UserModel (?). Please make sure
that the argument DatabaseConnection at index [0...
Liss asked 17/11, 2019 at 2:11
6
Solved
I m learning nodejs and mongodb altogether with getting MEAN application
my system specifications are
ubuntu 16.04 (64 bit)
node v 6.1.0
npm v 3.8.6
"mongodb": "^2.1.18",
"mongoose": "^4.4.1...
14
Solved
If I have this schema...
person = {
name : String,
favoriteFoods : Array
}
... where the favoriteFoods array is populated with strings. How can I find all persons that have "sushi" as their fa...
© 2022 - 2024 — McMap. All rights reserved.