-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start to implement the high-level wrapper on top of the drivers.
- Loading branch information
1 parent
ccbcd1e
commit 606f58d
Showing
2 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
var memory = require('./persistence/memory'); | ||
|
||
// Driver is the result of the new_connection method on a particular driver | ||
function Backend(driver) { | ||
this.driver = driver; | ||
} | ||
Backend.prototype = { | ||
|
||
// Define takes an optional table name, and a structure | ||
define: function () { | ||
|
||
var args = Array.prototype.slice.call(arguments, 0), | ||
name, columns, store, Resource; | ||
if (args[0] instanceof String) { | ||
name = args.shift(); | ||
} | ||
columns = args.shift(); | ||
if (name) { | ||
store = this.driver.get_store(name, columns); | ||
} else { | ||
store = memory.get_store(columns); | ||
} | ||
Resource = function (data) { }; | ||
Resource.prototype = { | ||
save: function () { } | ||
}; | ||
return Resource; | ||
} | ||
|
||
}; | ||
|
||
exports.Backend = Backend; |
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
var sys = require('sys'); | ||
|
||
function Store(conn, columns) { | ||
this.conn = conn; | ||
this.columns = columns; | ||
this.data = []; | ||
} | ||
Store.prototype = { | ||
get: function () { | ||
throw "TODO: Implement Store.get()"; | ||
}, | ||
find: function () { | ||
throw "TODO: Implement Store.find()"; | ||
}, | ||
each: function () { | ||
throw "TODO: Implement Store.each()"; | ||
}, | ||
all: function () { | ||
throw "TODO: Implement Store.all()"; | ||
}, | ||
save: function () { | ||
throw "TODO: Implement Store.save()"; | ||
}, | ||
remove: function () { | ||
throw "TODO: Implement Store.remove()"; | ||
}, | ||
nuke: function () { | ||
throw "TODO: Implement Store.nuke()"; | ||
} | ||
}; | ||
|
||
exports.get_store = function (columns) { | ||
return new Store(this, columns); | ||
}; |