Last active
April 20, 2016 03:16
-
-
Save mfpiccolo/9db5fb91cef8de578bbd2f5ef0d54d84 to your computer and use it in GitHub Desktop.
Concept for ruby-diesel
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 diesel = require("diesel") | |
var User = require('User'); | |
diesel.config({ | |
infer_schema = true | |
infer_models = true # I was thinking this would create Queriable structs with sane defaults based on schema | |
database_url = "postgres://localhost/ruby_diesel_dev" | |
model_mapping: { | |
users: User | |
} | |
}); |
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 diesel = require("diesel") | |
var usesr_table = diesel.users; | |
users = users_table.filter(diesel.users_table.first_name.eq(string)) | |
.limit(1) | |
.load() // would call diesel_load internally with an array of commands/query_fragments? | |
users // [User] |
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
// setup for Neon (or FFI) | |
fn load(call: Call) -> JsResult<JsString> { | |
let commands: Handle<JsArray> = try!(try!(call.arguments.require(scope, 0)).check::<JsArray>()); | |
let records = build_query!(commands); // Possible? | |
// Other fancy stuff | |
Ok(JsArray::new(scope, records.unwrap()) | |
} | |
register_module!(m, { | |
m.export("load", load) | |
}); |
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
class User { | |
constructor(id, first_name, last_name, email) { | |
this.id = id; | |
this.first_name = first_name; | |
this.last_name = last_name; | |
this.email = email; | |
} | |
} | |
module.exports = User; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment