Skip to content

Instantly share code, notes, and snippets.

@rbarros
Last active August 29, 2015 13:57
Show Gist options
  • Save rbarros/9474767 to your computer and use it in GitHub Desktop.
Save rbarros/9474767 to your computer and use it in GitHub Desktop.
jsonsql
var pages = [
{
"id": 1,
"slug": "empresa",
"page": "Empresa",
"title": "Empresa",
"subtitle": "Sub Empresa",
"text": "",
"created_at": "2013-07-12 12:15:25",
"updated_at": "2014-02-27 10:28:20"
},
{
"id": 2,
"slug": "servicos",
"page": "Serviços",
"title": "Serviços",
"subtitle": "Sub Serviços",
"text": "",
"created_at": "2013-07-12 12:15:25",
"updated_at": "2014-02-27 10:28:20"
}
]
jsonsql.query("select * from pages where (slug == 'empresa') order by title", pages);
/*
return:
[
Object
created_at: "2013-07-12 12:15:25"
id: 1
page: "Empresa"
slug: "empresa"
subtitle: "Sub Empresa"
text: ""
title: "Empresa"
updated_at: "2014-02-27 10:28:20"
__proto__: Object
]
*/
jsonsql.query("select * from pages order by title desc", pages);
/*
[
Object
created_at: "2013-07-12 12:15:25"
id: 2
page: "Serviços"
slug: "servicos"
subtitle: "Sub Serviços"
text: ""
title: "Serviços"
updated_at: "2014-02-27 10:28:20"
__proto__: Object
,
Object
created_at: "2013-07-12 12:15:25"
id: 1
page: "Empresa"
slug: "empresa"
subtitle: "Sub Empresa"
text: ""
title: "Empresa"
updated_at: "2014-02-27 10:28:20"
__proto__: Object
]
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment