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 Intaglio = require('intaglio'), | |
rest = require('../index'); | |
var mysqlRepository = new Intaglio.repositories.mysql({ | |
host: "192.168.33.10", | |
user: "test", | |
password: "", | |
database: "test_employees" | |
}), | |
ORM = Intaglio.ORM; |
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
{ | |
"_links": { | |
"foo": { | |
"create": { | |
"href": "http://api.example.com/foo", | |
"method": "POST" | |
}, | |
"find": { | |
"href": "http://api.example.com/foo?{field]={value}" | |
}, |
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 is just some test stuff for right meow | |
var ORM = require('./lib/orm'); | |
var mysqlRepository = new ORM.repositories.mysql({ | |
host: "192.168.33.10", | |
user: "test", | |
password: "", | |
database: "test_orm" | |
}); |
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
// Single ORM instance usage | |
ORM.create(mysqlRepository).then(function (orm) { | |
/* App logic goes here */ | |
orm.factory('foo'); | |
}, err); | |
// Multiple ORM instance usage | |
var ORMs = { | |
mysqlOrm: ORM.create(mysqlRepository), |
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
api.find = function (model, options, conditions) { | |
console.info(options); // {limit: 1} | |
return new RSVP.Promise(function (resolve, reject) { | |
console.info(options); // undefined WTF?! | |
var options = options || {}, | |
defaults = { | |
limit: null, | |
offset: null, | |
orderBy: null, | |
direction: null |
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
/** | |
* Helper for currying a function. | |
* | |
* ### Usage | |
* | |
* ```javascript | |
* // Some function you want to partially apply | |
* function someFunc(a, b, c, d) {return arguments;} | |
* | |
* // Curry the function |
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 user = ORM.factory('user'); | |
user.where(function (user) { | |
user.where('id').between(1, 10); | |
}).orWhere(function (user) { | |
user.where('id').between(100, 200); | |
}).orWhere({ | |
active: true, | |
banned: false | |
}).findAll(); |
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 is a WIP of potential usage of the ORM in a NodeJS implementation. Let's try implementing | |
* this as a module for other parts of the app to use. Less instantiation for later | |
*/ | |
var ORM = require('awesomeorm-base'), | |
repository = require('awesomeorm-repository-rest')('http://rest.example.com/schema'), | |
dataParser = require('awesomeorm-data-jsonapi'), | |
modelBuilder = require('awesomeorm-model-encasulated'); | |
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
/*! | |
* jQuery JavaScript Library v1.4.1 | |
* http://jquery.com/ | |
* | |
* Copyright 2010, John Resig | |
* Dual licensed under the MIT or GPL Version 2 licenses. | |
* http://jquery.org/license | |
* | |
* Includes Sizzle.js | |
* http://sizzlejs.com/ |
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
alert('Oh snap!'); |