diff --git a/package-shared/utils/serialize-query.js b/package-shared/utils/serialize-query.js index 7c3670f..d2a8f47 100644 --- a/package-shared/utils/serialize-query.js +++ b/package-shared/utils/serialize-query.js @@ -1,5 +1,7 @@ // @ts-check +const EJSON = require("./ejson"); + /** @type {import("../types").SerializeQueryFnType} */ function serializeQuery({ query }) { let str = "?"; @@ -7,10 +9,19 @@ function serializeQuery({ query }) { /** @type {string[]} */ const queryArr = []; + keys.forEach((key) => { if (!key || !query[key]) return; - queryArr.push(`${key}=${query[key]}`); + const value = query[key]; + + if (typeof value === "object") { + const jsonStr = EJSON.stringify(value); + queryArr.push(`${key}=${encodeURIComponent(String(jsonStr))}`); + } else if (typeof value === "string" || typeof value === "number") { + queryArr.push(`${key}=${encodeURIComponent(value)}`); + } }); + str += queryArr.join("&"); return str; } diff --git a/package.json b/package.json index c60453a..f309a8d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@moduletrace/datasquirel", - "version": "3.0.7", + "version": "3.0.8", "description": "Cloud-based SQL data management tool", "main": "index.js", "bin": {