-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fist mongoose model with some methods (probably not working)
- Loading branch information
antonlitvinenko
committed
Jul 10, 2011
1 parent
753fae7
commit b68b313
Showing
4 changed files
with
42 additions
and
35 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,29 @@ | ||
var mongoose = require('mongoose'); | ||
|
||
var Schema = mongoose.Schema, ObjectId = Schema.ObjectId; | ||
|
||
var Task = new Schema({ | ||
id: ObjectId, | ||
title: String | ||
}); | ||
|
||
mongoose.model('Task', Task); | ||
|
||
|
||
exports.tasks = function() { | ||
var datastore = []; | ||
|
||
return { | ||
add: function(title) { | ||
datastore.push({id: datastore.length, title: title, completed: false}); | ||
return datastore.length - 1; | ||
create: function(title, callback) { | ||
var Task = mongoose.model('Task'); | ||
var task = new Task(); | ||
task.title = title; | ||
task.save(callback); | ||
}, | ||
|
||
getAll: function() { | ||
return datastore; | ||
} | ||
} | ||
} | ||
}; | ||
|
This file contains 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