Skip to content

Instantly share code, notes, and snippets.

@csanz
Created August 1, 2011 09:07
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save csanz/1117833 to your computer and use it in GitHub Desktop.
Save csanz/1117833 to your computer and use it in GitHub Desktop.
Debugging your Mongoose Models Using Repl

Debugging your Mongoose Models Using Repl

This is a faster way to test your mongoose models. The example below was based on the expressjs-blog example here

Example

$node
> var mongoose = require('mongoose')
> var db = mongoose.connect('mongodb://localhost/blogsample')
> db.model('BlogPost', require('./app/models/blogpost'))
{ [Function: model] getLatestPosts: [Function], modelName: 'BlogPost' }
> db.model('BlogPost').findOne({}, function(err, data){ console.log(data) })
{ model: { [Function: model] getLatestPosts: [Function], modelName: 'BlogPost' }, op: 'findOne' }
> initializing...
{ is_active: true, date_created: Thu, 12 May 2011 06:05:57 GMT, title: 'Testing', body: 'Hello Blog Post', _id: 4dcb78c5218ef26905000025 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment