From c011ea1f0beec6fc3d988faeed0d570c13c899c7 Mon Sep 17 00:00:00 2001 From: Tim Caswell Date: Thu, 18 Mar 2010 03:12:48 -0400 Subject: [PATCH] Adjust the api to use node-style callbacks with error parameter. --- lib/persistence/plain.js | 9 ++++----- test.js | 11 +++++++---- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/persistence/plain.js b/lib/persistence/plain.js index 3942066..5145f75 100644 --- a/lib/persistence/plain.js +++ b/lib/persistence/plain.js @@ -1,12 +1,13 @@ var fs = require('fs'); var defer = process.nextTick; + exports.connect = function connect(filename, callback) { defer(function () { - callback({ + callback(null, { getStore: function getStore(name, callback) { defer(function () { - callback({ + callback(null, { get: function get(query, options, callback) {}, insert: function insert(data, callback) {}, update: function update(data, query, options, callback) {}, @@ -14,9 +15,7 @@ exports.connect = function connect(filename, callback) { }); }) }, - close: function (callback) { - defer(callback); - } + close: defer }); }); }; \ No newline at end of file diff --git a/test.js b/test.js index a96bffe..1da0927 100644 --- a/test.js +++ b/test.js @@ -9,12 +9,14 @@ Step( sys.puts("connect"); DbDriver.connect('mydb.json', this); }, - function getStore(db) { - sys.puts("getStore"); + function getStore(err, db) { + if (err) { throw err; } + sys.puts("getStore", sys.inspect(db)); this.db = db; db.getStore("people", this); }, - function testStore(people) { + function testStore(err, people) { + if (err) { throw err; } people.get(); people.update(); people.insert(); @@ -23,7 +25,8 @@ Step( sys.p(people); this.db.close(this); }, - function done() { + function done(err) { + if (err) { throw err; } sys.puts("done"); } );