Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node: update commands which return a Record with GlideString. #2207

Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
3e9264f
Spike: returning a record replacement with glide strings. (#418)
Yury-Fridlyand Aug 28, 2024
ff46c1f
Node: Add binary variant to `PUBSUB NUMSUB` and `PUBSUB SHARDNUMSUB` …
yipin-chen Aug 29, 2024
8542806
Fix tests.
Yury-Fridlyand Sep 4, 2024
e1904ae
Fix tests.
Yury-Fridlyand Sep 4, 2024
04e9334
Add binary variant to PUBSUB subscribe commands (#420)
yipin-chen Sep 5, 2024
b8bf37b
Merge remote-tracking branch 'upstream/main' into node/integ-valkey-2…
Yury-Fridlyand Sep 5, 2024
6d832a4
Fix processing cluster response. (#421)
Yury-Fridlyand Sep 5, 2024
eac46e9
Signed-off-by: Yury-Fridlyand <[email protected]>
Yury-Fridlyand Sep 6, 2024
0342235
Signed-off-by: Yury-Fridlyand <[email protected]>
Yury-Fridlyand Sep 6, 2024
2e910a6
Merge remote-tracking branch 'upstream/main' into node/integ-valkey-2…
Yury-Fridlyand Sep 6, 2024
915ad1c
Merge remote-tracking branch 'upstream/main' into node/integ-valkey-2…
Yury-Fridlyand Sep 7, 2024
ec4bd51
Merge remote-tracking branch 'upstream/main' into node/integ-valkey-2…
Yury-Fridlyand Sep 7, 2024
931f827
Signed-off-by: Yury-Fridlyand <[email protected]>
Yury-Fridlyand Sep 7, 2024
5a2499b
Merge remote-tracking branch 'upstream/main' into node/integ-valkey-2…
Yury-Fridlyand Sep 9, 2024
0d439ee
Signed-off-by: Yury-Fridlyand <[email protected]>
Yury-Fridlyand Sep 9, 2024
8764b9a
Merge remote-tracking branch 'upstream/main' into node/integ-valkey-2…
Yury-Fridlyand Sep 10, 2024
e98cfa5
Merge remote-tracking branch 'upstream/main' into node/integ-valkey-2…
Yury-Fridlyand Sep 10, 2024
2ac0609
Signed-off-by: Yury-Fridlyand <[email protected]>
Yury-Fridlyand Sep 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions node/npm/glide/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,11 @@ function initialize() {
GlideClient,
GlideClusterClient,
GlideClientConfiguration,
GlideRecord,
GlideString,
SortedSetDataType,
StreamEntryDataType,
HashDataType,
FunctionListOptions,
FunctionListResponse,
FunctionStatsSingleResponse,
Expand Down Expand Up @@ -202,7 +206,11 @@ function initialize() {
Decoder,
DecoderOption,
GeoAddOptions,
GlideRecord,
GlideString,
SortedSetDataType,
StreamEntryDataType,
HashDataType,
CoordOrigin,
MemberOrigin,
SearchOrigin,
Expand Down
18 changes: 11 additions & 7 deletions node/rust-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use napi::bindgen_prelude::Uint8Array;
use napi::{Env, Error, JsObject, JsUnknown, Result, Status};
use napi_derive::napi;
use num_traits::sign::Signed;
use redis::{aio::MultiplexedConnection, AsyncCommands, FromRedisValue, Value};
use redis::{aio::MultiplexedConnection, AsyncCommands, Value};
#[cfg(feature = "testing_utilities")]
use std::collections::HashMap;
use std::str;
Expand Down Expand Up @@ -195,13 +195,17 @@ fn redis_value_to_js(val: Value, js_env: Env, string_decoder: bool) -> Result<Js
Ok(js_array_view.into_unknown())
}
Value::Map(map) => {
let mut obj = js_env.create_object()?;
for (key, value) in map {
let field_name = String::from_owned_redis_value(key).map_err(to_js_error)?;
let value = redis_value_to_js(value, js_env, string_decoder)?;
obj.set_named_property(&field_name, value)?;
// Convert map to array of key-value pairs instead of a `Record` (object),
// because `Record` does not support `GlideString` as a key.
// The result is in format `GlideRecord<T>`.
let mut js_array = js_env.create_array_with_length(map.len())?;
for (idx, (key, value)) in (0_u32..).zip(map.into_iter()) {
let mut obj = js_env.create_object()?;
obj.set_named_property("key", redis_value_to_js(key, js_env, string_decoder)?)?;
obj.set_named_property("value", redis_value_to_js(value, js_env, string_decoder)?)?;
js_array.set_element(idx, obj)?;
}
Ok(obj.into_unknown())
Ok(js_array.into_unknown())
}
Value::Double(float) => js_env.create_double(float).map(|val| val.into_unknown()),
Value::Boolean(bool) => js_env.get_boolean(bool).map(|val| val.into_unknown()),
Expand Down
Loading
Loading