Questions for mongoose


6928

Node.js best practice for require

I am creating an Express application and using Mongoose to save data.
7004

Why can't my kittens speak when I retrieve them from the db

Following the guide on http://mongoosejs.com/docs/index.html and I´m clearly misunderstanding something basic. Why isn't the shema being applied to objects I retrieve?
756

Node.js and Mongoose - SEO Friendly URLs

I need to create SEO friendly URLs with Node.js, but before inserting document I'd like to check if there is already some other document which has url like that. I was searching for some module which
1249

How to Post data with express?

I have a pretty good understanding of how to use the app.get function, but I'm having trouble with the app.post.
1696

How to properly load-balance with Node.js / Mongoose / MongoDB + ConnectSet?

I'm using Node.js+Express+Mongoose to connect to my MongoDB replica set (3x instances).
7234

Mongoose - Increment with findOne

I'm working on some query with Mongoose where I need to skip and limit subdocuments, but in the same query I want to increment some field in document. Currently is my query built with chaining, bec...
296

Using Mongoose and MongoDB, can I combine a document update using req.body and an increment using $inc?

I want to update a document using the inbound form fields from req.body without having to break them apart and build out a $set. I have this working just fine. Now I want to add an increment to a f...
628

Does mongoose's “distinct” function support regex in a query?

I have the following bit of js in a node/mongoose project. I'm working on an autocomplete form. It works just fine with a regular "find", but I want to do a "distinct" find instead.
7127

How can I deny a user from logging in with mongoose-auth / everyauth

Using node.js / expressjs / mongoose / mongoose-auth / everyauth. All versions are up to date.
7638

How to sort a populated document in find request?

I would like to sort a populated Document from the collection i fetch, i get an error requesting it.
1054

mongoose middleware issues

the scenarios are as follows
4468

node.js, mongoose and mongodb a pain to install :(

I'm having trouble getting these 3 packages to install and work together. Here are the steps I took:
5550

Mongodb update with upsert and multi syntax

I am new to mongodb and so stressed out because of mongodb's incomplete documentation leaving me for trial and error... sadly, all my attempts are not working with no error, leaving me confused about
9616

Mongoose - Count subdocuments

I need to count subdocuments of the main document. Just an example of scheme:
4220
9802

Mongoose schema, set key variable

I'm using expressjs, mongodb and mongoose, I'm trying to update the counts object of the following schema:
8426

For loop in callback. Blocking?

//defining schemas, models, db connections, etc..
108

MongoDB creating, finding from and changing an array

Here's what I want to achieve in mongodb but as a javascript example.
9054

JavaScript object element is missing during Mongoose update query

I'm trying to update a new field of data into an existed document, but some of the data is not updating.
605

Mongoose sort by child value

I have a parent and child schema that looks like:
8296

Can't query mongoDB with mongoose in node.js

Suppose I have a collection in my mongoDB: db.co
5742

Callback recursive insertion Mongo with Node.js

i am doing an API with Node.js and MongoDB (Mongoose.js). And i making a "installation" script to populate the database with some example data, like users and other stuff.
9518

Group array after unwind and match

I have a twice nested schema:
4359

Mongoose - Proper way to initialize nested Schemas

If I have 3 models, one nested in another like below, how do I properly initialize them in my seed data function?
7221

Cast to ObjectId failed for value “xxx” at path “_id” when aggregating with mongoose

I am trying to use aggregation based on my mongoose model. I want to aggregate amounts based on categoryId. But when trying to access via routes url, I am getting this error. (Cast to ObjectId fail...
5596

Mongoose asynchronous defaults

It's not in the documentation, but I'm trying to figure out how to set asynchronous defaults with Mongoose. I see the model.pre("save", function(next){}) setup, but I have no idea how to mutate fie...
180

Removing many to many reference in Mongoose

One of my mongoose schemas is a many to many relationship:
5471

Mongoose upsert duplicate key error

I'm trying do an upsert using Mongoose, but I'm getting a duplicate key error for the very key that should trigger the upsert.
5892

Populate not working for an array of ObjectIDs

This is the implementation of my models :
9399

Strange Mongoose schema.js error - `options` may not be used as a schema pathname

In my schema, if I have options in metrics : [ { options : {} } ]then I get:
4800

Updating with mongoose, not returning any errors but neither updating

I am trying to learn CRUD with mongoose. I am only missing the update part. What am I doing wrong?
8046

In a large Mongo collection, how do I retrieve only ID's (or any other specific property) using mongoose?

Let's say I have a Person collection, and a Car collection, and that all people have a single car, and the Person document stores the Id of the car.
1185

Synchronous findOne with sort() in mongoose mongdb

I want to find document with the latest "sorting_index" field.
2363

findByIdAndUpdate With Multiple Subdocuments

So I'm working with NodeJS and MongoDB, and I'm making an endpoint that lets clients update their user profiles with several optional data fields. So, one of the update queries can look like this:
8066

Mongoose: Get full list of users

I have tried to use Mongoose to send the list of all users as follows:
6874

Multiple Schemas in a MongoDB (using Mongoose)

I'm utilizing MongoDB, Mongoose and Node to store user information for a game.
831

nodejs driver for mongodb fndAndModify

I have the following code:
5571
1810

Mongoose error handling in one place

I found in mongoose docs that I can handle errors generally, that I want. So you can do like:
7819

MongoDB - Populate GridFS files metadata in parent document

I am using NodeJS with Express, MongoDB, Mongoose and GridFS for uploading and retrieving files.
3959

Mongodb/Mongoose: Filling Array of ObjectIds (references)

I have a mongodb running (MEAN environment) with two collections (users and books). One of those collections (myusers) contains an array of Objectids (references to documents of books collection) as
3359

How to deal with nested data in Angular.js select in a form?

I have a node.js app where the form has a selector. The app loads the data from mongodb via mongoose and populates a nested referenced object. So my data looks like:
7840

Mongoose has no connect method when loading via Browserify

I am able to load Mongoose in an interactive node session and view its connect method like so...
3688

Mongoose ODM model creation problems

I am trying to create models in mongoose using an express app.
3206

Mongoose nested schema CastError

I have the following data which contains a nested schema:
415

Cannot pull from mongoose array

In my schema I have two arrays with users, invitedUsers and joinedUsers. Invited array is created from request body
6258

MongoDB using NOT and AND together

I'm trying to negate an $and clause with MongoDB and I'm getting a MongoError: invalid operator: $and message back. Basically what I want to achieve is the following: