Comparing version 0.20.0 to 0.20.1
@@ -30,2 +30,2 @@ /*! | ||
export declare const _plugJSBI: typeof plugJSBI; | ||
export declare const _edgedbJsVersion = "0.20.0"; | ||
export declare const _edgedbJsVersion = "0.20.1"; |
@@ -58,2 +58,2 @@ "use strict"; | ||
exports._plugJSBI = bigint_1.plugJSBI; | ||
exports._edgedbJsVersion = "0.20.0"; | ||
exports._edgedbJsVersion = "0.20.1"; |
@@ -45,2 +45,3 @@ import type { Executor } from "../ifaces"; | ||
run(cxn: Executor): any; | ||
runJSON(cxn: Executor): any; | ||
toEdgeQL(): string; | ||
@@ -51,2 +52,3 @@ is: any; | ||
run(cxn: Executor): Promise<setToTsType<Set>>; | ||
runJSON(cxn: Executor): Promise<string>; | ||
} : {}) & $tuplePathify<Set> & $arrayLikeIndexify<Set> & $jsonDestructure<Set>); | ||
@@ -53,0 +55,0 @@ export declare type stripSet<T> = "__element__" extends keyof T ? "__cardinality__" extends keyof T ? { |
@@ -12,2 +12,3 @@ import type { Executor } from "edgedb"; | ||
run(cxn: Executor, args: paramsToParamArgs<Params>): Promise<setToTsType<Set>>; | ||
runJSON(cxn: Executor, args: paramsToParamArgs<Params>): Promise<string>; | ||
}; | ||
@@ -14,0 +15,0 @@ export declare type $expr_WithParams<Params extends { |
@@ -39,2 +39,3 @@ import type {Executor} from "edgedb"; | ||
): Promise<setToTsType<Set>>; | ||
runJSON(cxn: Executor, args: paramsToParamArgs<Params>): Promise<string>; | ||
}; | ||
@@ -41,0 +42,0 @@ |
@@ -139,2 +139,3 @@ "use strict"; | ||
expr.run = query_1.$queryFunc.bind(expr); | ||
expr.runJSON = query_1.$queryFuncJSON.bind(expr); | ||
expr.is = isFunc.bind(expr); | ||
@@ -141,0 +142,0 @@ expr.toEdgeQL = toEdgeQL_1.$toEdgeQL.bind(expr); |
@@ -22,3 +22,3 @@ import { | ||
import {$toEdgeQL} from "./toEdgeQL"; | ||
import {$queryFunc} from "./query"; | ||
import {$queryFunc, $queryFuncJSON} from "./query"; | ||
@@ -219,2 +219,3 @@ function PathLeaf< | ||
expr.run = $queryFunc.bind(expr) as any; | ||
expr.runJSON = $queryFuncJSON.bind(expr) as any; | ||
expr.is = isFunc.bind(expr) as any; | ||
@@ -221,0 +222,0 @@ expr.toEdgeQL = $toEdgeQL.bind(expr); |
import type * as edgedb from "edgedb"; | ||
export declare function $queryFunc(this: any, cxn: edgedb.Executor, args: any): Promise<unknown>; | ||
export declare function $queryFuncJSON(this: any, cxn: edgedb.Executor, args: any): Promise<string>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.$queryFunc = void 0; | ||
exports.$queryFuncJSON = exports.$queryFunc = void 0; | ||
const reflection_1 = require("../reflection"); | ||
@@ -33,1 +33,16 @@ const json_1 = require("./json"); | ||
exports.$queryFunc = $queryFunc; | ||
async function $queryFuncJSON(cxn, args) { | ||
var _a; | ||
const expr = runnableExpressionKinds.has(this.__kind__) | ||
? this | ||
: (_a = wrappedExprCache.get(this)) !== null && _a !== void 0 ? _a : wrappedExprCache.set(this, (0, select_1.select)(this)).get(this); | ||
const _args = (0, json_1.jsonifyComplexParams)(expr, args); | ||
if (expr.__cardinality__ === reflection_1.Cardinality.One || | ||
expr.__cardinality__ === reflection_1.Cardinality.AtMostOne) { | ||
return cxn.querySingleJSON(expr.toEdgeQL(), _args); | ||
} | ||
else { | ||
return cxn.queryJSON(expr.toEdgeQL(), _args); | ||
} | ||
} | ||
exports.$queryFuncJSON = $queryFuncJSON; |
@@ -35,1 +35,22 @@ import type * as edgedb from "edgedb"; | ||
} | ||
export async function $queryFuncJSON( | ||
this: any, | ||
cxn: edgedb.Executor, | ||
args: any | ||
) { | ||
const expr = runnableExpressionKinds.has(this.__kind__) | ||
? this | ||
: wrappedExprCache.get(this) ?? | ||
wrappedExprCache.set(this, select(this)).get(this); | ||
const _args = jsonifyComplexParams(expr, args); | ||
if ( | ||
expr.__cardinality__ === Cardinality.One || | ||
expr.__cardinality__ === Cardinality.AtMostOne | ||
) { | ||
return cxn.querySingleJSON(expr.toEdgeQL(), _args); | ||
} else { | ||
return cxn.queryJSON(expr.toEdgeQL(), _args); | ||
} | ||
} |
{ | ||
"name": "edgedb", | ||
"version": "0.20.0", | ||
"version": "0.20.1", | ||
"description": "The official Node.js client library for EdgeDB", | ||
@@ -5,0 +5,0 @@ "homepage": "https://edgedb.com/docs", |
@@ -169,2 +169,11 @@ <div align="center"> | ||
You can also fetch the results as a JSON-serialized string with `.runJSON`. | ||
This serialization happens inside the database and is much faster than calling | ||
`JSON.stringify` yourself. | ||
```ts | ||
const result = await query.runJSON(client); | ||
// => '{"actors": [{"name": "Timothee Chalamet", ...}]}' | ||
``` | ||
## Contribute | ||
@@ -171,0 +180,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
985217
25158
195