Created
September 19, 2011 23:50
-
-
Save mikekunze/1227938 to your computer and use it in GitHub Desktop.
Quick Survey Mongoose
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mongoose.connect('mongodb://localhost/serveyus'); | |
var schema = mongoose.Schema, | |
ObjectID = schema.ObjectId; | |
mongoose.model('owner', new schema({ | |
username: { type: String }, | |
description: { type: String }, | |
email: { type: String }, | |
password: { type: String } | |
}); | |
mongoose.model('surveys', new schema({ | |
description: { type: String }, | |
ownerId: { type: ObjectId }, | |
createdOn: { type: Date }, | |
formJSON: { type: String } | |
}); | |
mongoose.model('results', new schema({ | |
surveyId: { type: ObjectId }, | |
formJSON: { type: String } | |
}); | |
var survey = mongoose.model('surveys'); | |
survey.add({ | |
description: 'our first survey', | |
ownerId: someonesOwnerId, | |
createdOn: Date.now(), | |
formJSON: ourResults | |
}); | |
survey.sync(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
can you give us a complete example of the api