diff --git a/crates/spin-js-engine/src/lib.rs b/crates/spin-js-engine/src/lib.rs index 1a882e1d..c9a791df 100644 --- a/crates/spin-js-engine/src/lib.rs +++ b/crates/spin-js-engine/src/lib.rs @@ -745,25 +745,25 @@ fn open_sqlite(context: &Context, _this: &Value, args: &[Value]) -> Result context.null_value()?, - sqlite::ValueResult::Integer(i) => context.value_from_i64(i)?, - sqlite::ValueResult::Real(r) => context.value_from_f64(r)?, - sqlite::ValueResult::Text(s) => context.value_from_str(&s)?, - sqlite::ValueResult::Blob(b) => context.array_buffer_value(&b)?, + sqlite::ValueResult::Integer(i) => context.value_from_i64(*i)?, + sqlite::ValueResult::Real(r) => context.value_from_f64(*r)?, + sqlite::ValueResult::Text(s) => context.value_from_str(s)?, + sqlite::ValueResult::Blob(b) => context.array_buffer_value(b)?, }; - js_row.append_property(js_value)?; + js_row.set_property(columns[index].to_string(),js_value)?; } js_rows.append_property(js_row)?; } + columns.serialize(&mut serializer)?; + let js_columns = serializer.value; + let result = context.object_value()?; result.set_property("columns", js_columns)?; result.set_property("rows", js_rows)?; diff --git a/spin-sdk/src/modules/spinSdk.ts b/spin-sdk/src/modules/spinSdk.ts index 230afb1b..3c1930e0 100644 --- a/spin-sdk/src/modules/spinSdk.ts +++ b/spin-sdk/src/modules/spinSdk.ts @@ -18,11 +18,11 @@ interface KvStore { type SqliteParam = number | string | ArrayBuffer type SqliteValue = null | number | string | ArrayBuffer + +type SqliteRow = Record interface SqliteReturn { columns: string[], - rows: [ - [SqliteValue] - ] + rows: SqliteRow[] } interface SqliteStore {