Created
May 21, 2012 14:55
-
-
Save kolektiv/2762765 to your computer and use it in GitHub Desktop.
SpahQL experiments
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 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