Last active
August 29, 2015 13:55
-
-
Save pfrazee/8694739 to your computer and use it in GitHub Desktop.
JSON DB api mockup
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
// DATA STORE API | |
importScripts('/js/guip/jsondb-1.0.0.js'); | |
var data = guip.jsonDB(); | |
data.select(where, { order:, limit:, offset:, groupBy: }) | |
data.get(id) | |
data.getMeta(id) | |
data.insert(doc, meta, perms) | |
data.update(id|where, doc, meta, perms) | |
data.updateMeta(id|where, meta) | |
data.updatePerms(id|where, perms) | |
data.delete(id) | |
where = { mosql query } | |
doc = { * } | |
meta = { * } | |
perms = { select:, update:, delete: } | |
data.insert({ name: 'Bob', type: 'user' }, { rel: 'guipedia.com/rel/user' }); | |
// => 201 { id: 3 } | |
data.select({ id: 3 }, { limit: 1 }); | |
// => 200 [{ id: 3, name: 'Bob', type: 'user' }] | |
data.get(3); | |
// => 200 { id: 3, name: 'Bob', type: 'user' } | |
data.getMeta(3); | |
// => 200 { id: 3, rel: 'guipedia.com/rel/user' } | |
data.update(3, { type: 'luser' }); | |
// => 200 { count: 1 } | |
data.update({ id: 3, type: 'asdf' }, { type: 'luser' }); | |
// => 200 { count: 0 } | |
data.delete(3); | |
// => 204 | |
data.insert({ name: 'Alice', type: 'user' }, null, { update: guip.ident.AUTHOR|guip.ident.GROUP1, delete: guip.ident.NOBODY }); | |
// => 201 { id: 4 } | |
// --- | |
// IDENTITY API | |
importScripts('/js/guip/ident-1.0.0.js'); | |
guip.ident.get() | |
guip.ident.isa(desc, roles) | |
guip.ident.NOBODY = 0 | |
guip.ident.PUBLIC = 00000001 | |
guip.ident.OWNER = 00000010 | |
guip.ident.GROUP1 = 00000100 | |
guip.ident.GROUP2 = 00001000 | |
guip.ident.GROUP3 = 00010000 | |
guip.ident.GROUP4 = 00100000 | |
guip.ident.GROUP5 = 01000000 | |
guip.ident.GROUP6 = 10000000 | |
guip.ident.get() | |
// => 200 { id: 'pfraze', is_admin: true, role: 12 } | |
guip.ident.isa(userdata, guip.ident.GROUP1) | |
// -> true | |
guip.ident.isa(userdata, guip.ident.GROUP2) | |
// -> true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment