Skip to content

Instantly share code, notes, and snippets.

@bitmage
Created November 19, 2012 19:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bitmage/7b93d0e21dc21f520c48 to your computer and use it in GitHub Desktop.
Save bitmage/7b93d0e21dc21f520c48 to your computer and use it in GitHub Desktop.
Mongoose Getters Should Apply to Create
should = require 'should'
db = require 'mongoose'
db.connect 'mongodb://localhost:27017/test'
{Schema} = db
widget = new Schema
name: String
widget.path('_id').get (_id) -> _id.toString()
Widget = db.model 'Widget', widget
Widget.create {name: 'foo'}, (err, w) ->
(typeof w._id).should.eql 'string'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment