Skip to content

Commit

Permalink
Merge pull request #11 from agonbina/master
Browse files Browse the repository at this point in the history
Closes #8, and #10. Added Getter and Setter for model and schema internal variables, and added `feathers-plugin` keyboard, and cleaned up comments and console.log calls.
  • Loading branch information
Glavin001 committed Apr 23, 2014
2 parents 2739c2b + 356d3d4 commit d51ed77
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,5 @@ Session.vim
# proportion of contributors will probably not be using SublimeText
# *.sublime-project

# === Webstorm ===
.idea
15 changes: 11 additions & 4 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ module.exports = function(modelName, schema, mongoose) {
return this;
}

// Getter methods for 'model' and 'schema'
Store.prototype.getModel = function() {
return this.model;
};

Store.prototype.getSchema = function () {
return this.schema;
};

// Helpers
var parseQuery = function(query) {
if (typeof query !== 'object')
Expand All @@ -45,7 +54,7 @@ module.exports = function(modelName, schema, mongoose) {
return query;
};

// Returns a Todo by it's id
// Returns a Model by it's id
Store.prototype.find = function (params, callback) {
if (typeof params === 'function') {
callback = params;
Expand All @@ -71,16 +80,14 @@ module.exports = function(modelName, schema, mongoose) {
};

Store.prototype.create = function (data, params, callback) {
// Create our actual Todo object so that we only get what we really want
// Create our actual Model object so that we only get what we really want
var obj = new this.model(data);
obj.save(function (err, data) {
//console.log(err, data);
callback(err, data);
});
};

Store.prototype.update = function (id, data, params, callback) {
console.log('UPDATE', id, data, params);
this.model.findByIdAndUpdate(id, data, { upsert: true }, function(err, data) {
return callback(err, data);
});
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
},
"keywords": [
"feathers",
"feathers-plugin",
"REST",
"Socket.io",
"realtime",
Expand Down

0 comments on commit d51ed77

Please sign in to comment.