thegraph-store-postgres-diesel: Update to new Store trait
@@ -162,9 +162,9 @@ impl StoreTrait for Store {
.map_err(|_| ())
}
- fn find(&self, query: StoreQuery) -> Result<Vec<store::Entity>, ()> {
- use ourschema::entities::columns::*;
- use ourschema::*;
+ fn find(&self, query: StoreQuery) -> Result<Vec<Entity>, ()> {
+ use db_schema::entities::columns::*;
+ use db_schema::*;
// Datasource hardcoded at the moment
let _datasource: String = String::from("memefactory");
@@ -178,13 +178,13 @@ impl StoreTrait for Store {
.into_boxed::<Pg>();
// Add specified filter to query
-
- for filter in query.filters {
+ match query.filter {
+ Some(StoreFilter::And(filters)) => {
+ for filter in filters {
match filter {
StoreFilter::Contains(attribute, value) => {
match value {
Value::String(query_value) => {
- info!(&self.logger, "query value for contains filter"; "string" => format!("{:#?}", &query_value));
diesel_query = diesel_query.filter(
sql("data -> ")
.bind::<Text, _>(attribute)
@@ -278,9 +278,14 @@ impl StoreTrait for Store {
}
};
}
- _ => panic!("Error with find query: unsupported filter type"),
+
+ // We will add support for more filters later
+ _ => unimplemented!(),
};
}
+ }
+ _ => unimplemented!(),
+ }
// Add order by filters to query
match query.order_by {
@@ -321,7 +326,7 @@ impl StoreTrait for Store {
.map(|r| {
r.into_iter()
.map(|x| {
- serde_json::from_value::<store::Entity>(x)
+ serde_json::from_value::<Entity>(x)
.expect("Error deserializing results of get")
})
.collect()
