Skip to content

Commit a0540ee

Browse files
RSDK-9504: accept bson queries in mql function (#431)
1 parent 60f9df8 commit a0540ee

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/app/data-client.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ describe('DataClient tests', () => {
249249

250250
it('get tabular data from MQL', async () => {
251251
const promise = await subject().tabularDataByMQL('some_org_id', [
252-
new TextEncoder().encode('some_mql_query'),
252+
{ query: 'some_mql_query' },
253253
]);
254254
const result = promise as typeof data;
255255
expect(result[0]?.key1).toBeInstanceOf(Date);

src/app/data-client.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,17 @@ export class DataClient {
155155
* @param query The MQL query to run as a list of BSON documents
156156
* @returns An array of data objects
157157
*/
158-
async tabularDataByMQL(organizationId: string, query: Uint8Array[]) {
158+
async tabularDataByMQL(
159+
organizationId: string,
160+
query: Uint8Array[] | Record<string, Date | JsonValue>[]
161+
) {
162+
const binary: Uint8Array[] =
163+
query[0] instanceof Uint8Array
164+
? (query as Uint8Array[])
165+
: query.map((value) => BSON.serialize(value));
159166
const resp = await this.dataClient.tabularDataByMQL({
160167
organizationId,
161-
mqlBinary: query,
168+
mqlBinary: binary,
162169
});
163170
return resp.rawData.map((value) => BSON.deserialize(value));
164171
}

0 commit comments

Comments
 (0)