Skip to content

Instantly share code, notes, and snippets.

@kolektiv
Created May 21, 2012 14:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kolektiv/2762765 to your computer and use it in GitHub Desktop.
Save kolektiv/2762765 to your computer and use it in GitHub Desktop.
SpahQL experiments
var spahql = require('spahql');
var response = {
_id: '0',
text: 'some text',
sources:
[
{
_id: '1',
innerText: 'some inner text'
},
{
_id: '2',
innerText: 'some more inner text'
}
]
};
var db = spahql.db(response);
var result = db.select('//_id').replaceAll('id');
console.log(result.value());
console.log(db.value());
// result:
{ '0':
{ path: '/_id',
value: 'id',
sourceData: { _id: 'id', text: 'some text', sources: [Object] } },
'1':
{ path: '/sources/0/_id',
value: 'id',
sourceData: { _id: 'id', text: 'some text', sources: [Object] } },
'2':
{ path: '/sources/1/_id',
value: 'id',
sourceData: { _id: 'id', text: 'some text', sources: [Object] } },
length: 3 }
// result.value()
'id'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment