Skip to content

Instantly share code, notes, and snippets.

@mikekunze
Created September 19, 2011 23:50
Show Gist options
  • Save mikekunze/1227938 to your computer and use it in GitHub Desktop.
Save mikekunze/1227938 to your computer and use it in GitHub Desktop.
Quick Survey Mongoose
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();
@Gryffind96
Copy link

can you give us a complete example of the api

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment