add json array to serde_json::Value db deserialization without Raw
This commit is contained in:
parent
72797532b6
commit
77d7e8a3ad
2 changed files with 9 additions and 8 deletions
|
@ -351,6 +351,10 @@ impl<'a, 'de: 'a> de::Deserializer<'de> for &'a mut Deserializer<'de> {
|
||||||
|
|
||||||
match self.record_peek_byte() {
|
match self.record_peek_byte() {
|
||||||
| Some(b'{') => self.deserialize_map(visitor),
|
| Some(b'{') => self.deserialize_map(visitor),
|
||||||
|
| Some(b'[') => serde_json::Deserializer::from_slice(self.record_next())
|
||||||
|
.deserialize_seq(visitor)
|
||||||
|
.map_err(Into::into),
|
||||||
|
|
||||||
| _ => self.deserialize_str(visitor),
|
| _ => self.deserialize_str(visitor),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -947,13 +947,12 @@ impl Service {
|
||||||
user_id: &UserId,
|
user_id: &UserId,
|
||||||
profile_key: &str,
|
profile_key: &str,
|
||||||
) -> Result<serde_json::Value> {
|
) -> Result<serde_json::Value> {
|
||||||
|
let key = (user_id, profile_key);
|
||||||
self.db
|
self.db
|
||||||
.useridprofilekey_value
|
.useridprofilekey_value
|
||||||
.qry(&(user_id, profile_key))
|
.qry(&key)
|
||||||
.await
|
.await
|
||||||
.deserialized::<Raw<serde_json::Value>>()
|
.deserialized()
|
||||||
.map(serde_json::to_value)?
|
|
||||||
.map_err(Into::into)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets all the user's profile keys and values in an iterator
|
/// Gets all the user's profile keys and values in an iterator
|
||||||
|
@ -961,16 +960,14 @@ impl Service {
|
||||||
&'a self,
|
&'a self,
|
||||||
user_id: &'a UserId,
|
user_id: &'a UserId,
|
||||||
) -> impl Stream<Item = (String, serde_json::Value)> + 'a + Send {
|
) -> impl Stream<Item = (String, serde_json::Value)> + 'a + Send {
|
||||||
type KeyVal = ((Ignore, String), Raw<serde_json::Value>);
|
type KeyVal = ((Ignore, String), serde_json::Value);
|
||||||
|
|
||||||
let prefix = (user_id, Interfix);
|
let prefix = (user_id, Interfix);
|
||||||
self.db
|
self.db
|
||||||
.useridprofilekey_value
|
.useridprofilekey_value
|
||||||
.stream_prefix(&prefix)
|
.stream_prefix(&prefix)
|
||||||
.ignore_err()
|
.ignore_err()
|
||||||
.ready_filter_map(|((_, key), val): KeyVal| {
|
.map(|((_, key), val): KeyVal| (key, val))
|
||||||
Some((key, serde_json::to_value(val).ok()?))
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets a new profile key value, removes the key if value is None
|
/// Sets a new profile key value, removes the key if value is None
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue