Permalink
Browse files

[fix]fix hits feature

  • Loading branch information...
lbj96347 committed Nov 6, 2013
1 parent 8b0d0d4 commit 319a0f110c5bf716eeff86182edb844366bd283b
Showing with 6 additions and 2 deletions.
  1. +5 −1 lib/short.js
  2. +1 −1 models/prototype.js
View
@@ -56,7 +56,11 @@ exports.generate = function(document) {
exports.retrieve = function(hash) {
var promise = new Promise();
- var retrievePromise = ShortURL.findOne({ hash : hash });
+ var query = { hash : hash }
+ , update = { $inc: { hits: 1 } }
+ , options = { multi: true };
+ var retrievePromise = ShortURL.findOne(query);
+ ShortURL.update( query, update , options , function (){ } );
retrievePromise.then(function(ShortURLObject) {
if (ShortURLObject && ShortURLObject !== null) {
promise.resolve(ShortURLObject);
View
@@ -53,7 +53,7 @@ exports.Model.prototype.findOne = function(query, fields, options) {
*/
exports.Model.prototype.update = function(query, document, options) {
- var promise = new APP.Promise()
+ var promise = new Promise()
this.baseModel.update(query, document, options, function(error, affected) {
if (error) {
promise.reject(error, true);

0 comments on commit 319a0f1

Please sign in to comment.