-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
.runJSON
to query builder expressions (#316)
* Add `.runJSON` * Release v0.20.1
- Loading branch information
1 parent
3cb5c0f
commit 231feb0
Showing
11 changed files
with
178 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "edgedb", | ||
"version": "0.20.0", | ||
"version": "0.20.1", | ||
"description": "The official Node.js client library for EdgeDB", | ||
"homepage": "https://edgedb.com/docs", | ||
"author": "EdgeDB <[email protected]>", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import type * as edgedb from "edgedb"; | ||
import {$} from "edgedb"; | ||
import * as tc from "conditional-type-checks"; | ||
|
||
import e, {$infer} from "../dbschema/edgeql-js"; | ||
import {number} from "../dbschema/edgeql-js/modules/std"; | ||
import {setupTests, teardownTests, TestData} from "./setupTeardown"; | ||
|
||
let client: edgedb.Client; | ||
let data: TestData; | ||
|
||
beforeAll(async () => { | ||
const setup = await setupTests(); | ||
({client, data} = setup); | ||
}); | ||
|
||
afterAll(async () => { | ||
await teardownTests(client); | ||
}); | ||
|
||
test("basic select", async () => { | ||
const query = e.select(e.Movie, movie => ({ | ||
title: true, | ||
order_by: movie.title, | ||
})); | ||
|
||
const result = await query.runJSON(client); | ||
tc.assert<tc.IsExact<typeof result, string>>(true); | ||
expect(result).toEqual( | ||
'[{"title" : "Captain America: Civil War"}, {"title" : "The Avengers"}]' | ||
); | ||
}); | ||
|
||
test("select one", async () => { | ||
const query = e.select(e.Movie, movie => ({ | ||
title: true, | ||
filter: e.op(movie.title, "=", "The Avengers"), | ||
})); | ||
|
||
const result = await query.runJSON(client); | ||
tc.assert<tc.IsExact<typeof result, string>>(true); | ||
expect(result).toEqual('{"title" : "The Avengers"}'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters