Closed selfup closed 8 years ago
Once the serde_json_schema PR is merged, write a find function that let's the user dictate the table and the id of the record in the records Hash.
serde_json_schema
pub fn find<T: Serialize + Deserialize>(table: &str, id: &str) -> HashMap<String, T> {
Something like this would be a good start.
An additional option would be to build a separate Struct to return a nice object to our users.
#[derive(Serialize, Deserialize, PartialEq, Debug)] pub struct SingleRecord<T: Serialize> { pub record: HashMap<String, T>, } pub fn find<T: Serialize + Deserialize>(table: &str, id: &str) -> SingleRecord<T> {
This way you can use serde to serialize/deserialize a good object.
serde
serialize/deserialize
Just some high level examples.
I wrote two helper methods to be more DRY on the find branch: Here are the LOC to look at
find
This is the branch you should be working on after the serde_json_schema PR is merged.
Once the
serde_json_schema
PR is merged, write a find function that let's the user dictate the table and the id of the record in the records Hash.Something like this would be a good start.
An additional option would be to build a separate Struct to return a nice object to our users.
This way you can use
serde
toserialize/deserialize
a good object.Just some high level examples.
I wrote two helper methods to be more DRY on the
find
branch: Here are the LOC to look atThis is the branch you should be working on after the
serde_json_schema
PR is merged.