Tagged Questions
2
votes
6answers
2k views
How can I save multiple documents concurrently in Mongoose/Node.js?
At the moment I use save to add a single document. Suppose I have an array of documents that I wish to store as single objects. Is there a way of adding them all with a single function call and then ...
10
votes
5answers
5k views
Node + Mongoose: Get last inserted ID?
I want to retrieve the last inserted _id, using mongoose as MongoDB wrapper for node.js. I've found the following tutorial, but I can't change any node modules because the app runs on a public server:
...
9
votes
5answers
3k views
Has Mongoose support findAndModify Mongodb method?
Below is the code throwing error "TypeError: Object # has no method 'findAndModify'"
Please help me on this!
// defining schema for the "counters" table
var tableSchema = new Schema({
_id ...
4
votes
2answers
3k views
How to update embedded document in mongoose?
I've looked through the mongoose API, and many questions on SO and on the google group, and still can't figure out updating embedded documents.
I'm trying to update this particular userListings ...
12
votes
1answer
2k views
Dealing with schema changes in Mongoose
What's the best practice (or tool) for updating/migrating Mongoose schemas as the application evolves?
12
votes
1answer
3k views
is there a mongoose connect error callback
how can i set a callback for the error handling if mongoose isn't able to connect to my DB?
i know of
connection.on('open', function () { ... });
but is there something like
...
6
votes
2answers
3k views
Mongoose Unique index not working!
I'm trying to let MongoDB detect a duplicate value based on its index. I think this is possible in MongoDB, but through the Mongoose wrapper things appear to be broken. So for something like this:
...
2
votes
1answer
661 views
mongoose (mongodb) Alias _id field
Is it possible with mongoose use a different name, in my case uppercase 'ID', as an alias for the schema _id field?
Would I need to add a virtual or is there another way of setting this up?
Any help ...
1
vote
1answer
42 views
Specify schema in mongoose
I was wondering what the best way to define this schema is:
Newsitem can only have 1 userID and 1 task ID.
A Task can belong to many newsitems.
A user can belong to many newsitems
I've searched ...
1
vote
5answers
290 views
Validating password / confirm password with Mongoose schema
I have a userSchema that looks like this:
var userSchema = new Schema({
name: {
type: String
, required: true
, validate: [validators.notEmpty, 'Name is empty']
}
, username: ...
0
votes
1answer
306 views
Field not showing in Mongoose aggregation
I'm trying to get a count of all distinct departments. I'd like the results to contain the deptType, deptName and the count. The grouping works, and results show deptType and dCount, but not deptName. ...
0
votes
1answer
533 views
How to insert a doc into mongodb using mongoose and get the generated id?
I'm using mongoose to operate mongodb. Now, for testing, I want to inserting some data into mongodb by native connection.
But the question is how to get the generated id after inserting?
I tried:
...
19
votes
4answers
13k views
How do I update/upsert a document in Mongoose?
Perhaps it's the time, perhaps it's me drowning in sparse documentation and not being able to wrap my head around the concept of updating in Mongoose :)
Here's the deal:
I have a contact schema and ...
22
votes
6answers
7k views
How to paginate with Mongoose in node.js?
I am writing a webapp with Node.js and mongoose. How can I paginate the results I get from a .find() call? I would like a functionality comparable to "LIMIT 50,100" in SQL.
9
votes
6answers
4k views
Is there a DB viewer for MongoDB on Node.js?
I'm looking for a tool that will provide a clean web interface to access a MongoDB database running on Node.js. The biggest feature I could think of would be a clean way to view and edit the data in a ...