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
/** | |
* A wrapper store to aggregate stores of different types as nested child stores | |
*/ | |
exports.MultiType = function(entityStores) { | |
openObjectStore: function(storeName){ | |
// handle nested stores with nested paths | |
var store = entityStores[storeName]; | |
if(store) { | |
return store; |
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
var request = require("jsgi-client").request; | |
when(request({ | |
method: "GET", | |
url: "http://google.com/" | |
}, function(response) { | |
print("why don't you print?!"); | |
})); |
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
/** | |
* A store wrapper for collecting multiple object stores into packages | |
*/ | |
var Model = require("model").Model; | |
exports.Package = function(name, model, stores) { | |
if(!stores){ | |
stores = model; | |
model = {}; |
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
/* | |
* CouchDB store | |
*/ | |
var Model = require("model").Model, | |
request = require("jsgi-client").request, | |
when = require("promise").when, | |
error = require("jsgi/error"); | |
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
var couch = require("store/couch"); | |
var couchStore = couch.Database("test_suite_db"); | |
var TestModel = require("model").Model("TestModel", couchStore, { | |
prototype: { | |
testMethod: function(){ | |
return this.foo; | |
} | |
}, | |
staticMethod: function(id){ | |
return this.get(id); |
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
// exports defined out here. | |
exports.foo = "bar" | |
require( | |
{sys: "sys", File: "file", sqlite: "persistence/sqlite3"} | |
)(function () { | |
sys.p(File); | |
// Rest of program here | |
}); |
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
var JSFile = require("store/js-file").JSFile; | |
var dataPath = (require("settings").dataFolder || "data") + "/"; | |
var foo = Package("foo"); | |
foo.bar = foo.Package("bar"); | |
foo.bar.baz = foo.bar.SubModel("baz", | |
JSFile(dataPath + "foo.bar.baz.json"), | |
{ | |
prototype: { |
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
// this fails with MethodNotAllowedError: SubModel is not allowed | |
var JSFile = require("store/js-file").JSFile; | |
var dataPath = (require("settings").dataFolder || "data") + "/"; | |
var Package = require("package").Package; | |
var foo = Package("foo"); | |
foo.bar = foo.Package("bar"); | |
foo.bar.baz = foo.bar.SubModel("baz", |
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
var MyClass = Model("MyClass", | |
require("store/xmldb").PropertyStore()), | |
{ | |
properties: { | |
foo: {type: String}, | |
bar: {type: Integer, optional: true, index: true}, | |
baz: {type: Date, optional: true}, | |
xml: String /*perhaps some kind of special class I can test with instanceof*/ | |
} | |
} |
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
// simple repl test | |
var test = require("model").Model("test", require("store/js-file").JSFile(), | |
{ | |
properties: { | |
foo: {type: "string"}, | |
bar: {type: "integer", optional: true} | |
} | |
} | |
); |
OlderNewer