Crates.io | data-query |
lib.rs | data-query |
version | 0.1.6 |
source | src |
created_at | 2022-06-01 03:07:00.226995 |
updated_at | 2022-06-13 01:06:56.167462 |
description | Query library that allows for Querying Serializable data using string queries |
homepage | |
repository | https://github.com/nebula-technologies/data-query |
max_upload_size | |
id | 597842 |
size | 33,423 |
Data Query is a library that allows query any Serializable data.
It currently supports only a few structures of querying.
.some-key.some-other-key
.some-array[0]
- getting key 0 in the array.some-array[0-2,6]
- getting key 0,1,2 and 6.some-map[key1, key2]
- Treating the array as a map, and getting key1 and key2More will be added later, see TODO
To query the data the following can be used:
precompile_lex!
macro will build the lexical from the query string that has already been given.
Prebuilding the lexical operations reduces the amount of processing required
let lex = precompile_lex!(.friends[1].name);
let data = User::default();
let query_res = query(data, lex);
println!("{:?}", query_res.unwrap());
If the query is dynamically created, it might be better to just compile the lexical on the fly.
let lex = compile(".friends[1,2].name").unwrap();
let data = User::default();
let query_res = query(data, lex);
println!("{:?}", query_res.unwrap());
At the moment there is only 1 todo because it very high on the list.