Skip to content
This repository has been archived by the owner on Mar 4, 2019. It is now read-only.

Commit

Permalink
Added sync goodies for documents, bumped version
Browse files Browse the repository at this point in the history
  • Loading branch information
subsonic committed Aug 12, 2015
1 parent 283263c commit c9230a0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/document_table.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var util = require('util');
var Document = require("./document");
var Where = require("./where");
var ArgTypes = require("./arg_types");
var DA = require("deasync");

//Searching query for jsonb docs
exports.searchDoc = function(args, next){
Expand All @@ -28,6 +29,7 @@ exports.searchDoc = function(args, next){

this.executeDocQuery(sql, [args.term], next);
};
exports.searchDocSync = DA(this.serchDoc);

exports.saveDoc = function(args, next){
assert(_.isObject(args), "Please pass in the document for saving as an object. Include the primary key for an UPDATE.");
Expand All @@ -50,6 +52,7 @@ exports.saveDoc = function(args, next){
}
this.executeDocQuery(sql, params, {single : true}, next)
};
exports.saveDocSync = DA(this.saveDoc);

exports.findDoc = function(){
var args = ArgTypes.findArgs(arguments);
Expand All @@ -68,6 +71,7 @@ exports.findDoc = function(){
this.executeDocQuery(sql, where.params, args.options, args.next);
}
};
exports.findDocSync = DA(this.findDoc);

this.getWhereForDoc = function(conditions) {
var where = {};
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "massive",
"version": "2.0.5",
"version": "2.0.6",
"description": "A small query tool for Postgres that embraces json and makes life simpler",
"main": "index.js",
"bin": {
Expand Down
4 changes: 4 additions & 0 deletions test/sync_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,8 @@ describe("Synchronous goodies", function(){
var product = db.products.findOneSync({id : 1});
assert.equal(1,product.id);
});
it('finds a document', function () {
var doc = db.docs.findDocSync(1);
assert.equal(1, doc.id);
});
});

0 comments on commit c9230a0

Please sign in to comment.