-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add more documentation for @dataplan/pg; minor fixes (#372)
- Loading branch information
Showing
26 changed files
with
1,451 additions
and
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@dataplan/pg": patch | ||
--- | ||
|
||
Remove pgSelectSingle.expression; use the equivalent method | ||
pgSelectSingle.select instead. |
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,5 @@ | ||
--- | ||
"graphile-export": patch | ||
--- | ||
|
||
Optimize away even more IIFEs |
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
22 changes: 22 additions & 0 deletions
22
grafast/website/grafast/step-library/dataplan-pg/pgClassExpression.md
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,22 @@ | ||
--- | ||
sidebar_position: 3 | ||
--- | ||
|
||
# pgClassExpression | ||
|
||
A pgClassExpression represents the value of an SQL expression extracted from a | ||
`pgSelectSingle`, `pgUnionAllSingle` or similar step. | ||
|
||
You won't construct a pgClassExpression directly, normally you'll get it from | ||
`$pgSelectSingle.select(...)`, `resource.execute(...)` or similar methods. | ||
|
||
## pgClassExpression.get(attr) | ||
|
||
The most commonly used method on a `pgClassExpression`, this gets a step | ||
representing the value of the given attribute from the expression; only | ||
applicable when the expression represents a composite type. | ||
|
||
## Not opaque | ||
|
||
Unlike a `pgSelectSingle`, a `pgClassExpression` is _not_ opaque, so it's fine | ||
to use it directly as a dependency of any other step. |
48 changes: 48 additions & 0 deletions
48
grafast/website/grafast/step-library/dataplan-pg/pgCondition.md
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,48 @@ | ||
# pgCondition | ||
|
||
This "modifier step" (**not** an ExecutableStep) is commonly acquired from | ||
`$pgSelect.wherePlan()`, `$pgSelect.havingPlan()`, or similar methods. It's | ||
useful for building up a condition (`WHERE` or `HAVING` clause) bit by bit. | ||
|
||
:::tip | ||
|
||
This is an advanced step, you probably will never use it unless you're building | ||
advanced filtering capabilities into your GraphQL schema. | ||
|
||
::: | ||
|
||
pgConditions are created with a parent (a PgConditionCapableStep - typically another PgConditionStep, a PgSelectStep, or similar) and a mode: | ||
|
||
- `PASS_THRU` - passes conditions directly up to the parent | ||
- `AND` - combines conditons with `AND` and passes the result up to the parent | ||
- `OR` - combines the conditions with `OR` and passes the result up to the parent | ||
- `NOT` - combines the conditons with `AND`, groups them together and does a `NOT` of the result, which is then passed up to the parent | ||
- `EXISTS` - builds an `EXISTS(...)` expression utilising the conditions and passes it up to the parent | ||
|
||
## $pgCondition.orPlan() | ||
|
||
Returns a child pgCondition in `OR` mode. | ||
|
||
## $pgCondition.andPlan() | ||
|
||
Returns a child pgCondition in `AND` mode. | ||
|
||
## $pgCondition.notPlan() | ||
|
||
Returns a child pgCondition in `NOT` mode. | ||
|
||
## $pgCondition.existsPlan(options) | ||
|
||
Returns a child pgCondition in `EXISTS` mode with the given options. | ||
|
||
## $pgCondition.where(condition) | ||
|
||
Adds `condition` to the list of conditions. Cannot be used in "having" mode. | ||
|
||
## $pgCondition.having(condition) | ||
|
||
Adds `condition` to the list of conditions. Cannot be used unless in "having" mode. | ||
|
||
## $pgCondition.placeholder($step, codec) | ||
|
||
Equivalent to `$pgSelect.placeholder($step, codec)` |
24 changes: 24 additions & 0 deletions
24
grafast/website/grafast/step-library/dataplan-pg/pgDeleteSingle.md
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,24 @@ | ||
# pgDeleteSingle | ||
|
||
Deletes a single row from the given `resource`, identified by the given unique | ||
spec (similar to the spec you'd pass to `resource.get(...)`). | ||
|
||
```ts | ||
const $deletedUser = pgDeleteSingle(usersResource, { | ||
id: $id, | ||
}); | ||
``` | ||
|
||
## $pgDeleteSingle.get(attr) | ||
|
||
Returns a PgClassExpressionStep representing the given attribute from the | ||
deleted row. This is achieved by selecting the value using the | ||
`DELETE FROM ... WHERE ... RETURNING ...` syntax. | ||
|
||
```ts | ||
const $username = $deletedUser.get("username"); | ||
``` | ||
|
||
## $pgDeleteSingle.record() | ||
|
||
Returns a PgClassExpressionStep representing the full record that was deleted. |
43 changes: 43 additions & 0 deletions
43
grafast/website/grafast/step-library/dataplan-pg/pgInsertSingle.md
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 @@ | ||
# pgInsertSingle | ||
|
||
Inserts a single row into the given `resource`, setting the given attributes (if any). | ||
|
||
```ts | ||
const $insertedUser = pgInsertSingle(usersResource, { | ||
username: $username, | ||
}); | ||
``` | ||
|
||
## $pgInsertSingle.set(attr, $value) | ||
|
||
Adds another attribute to be inserted: | ||
|
||
```ts | ||
const $insertedUser = pgInsertSingle(usersResource); | ||
$insertedUser.set("username", $username); | ||
$insertedUser.set("bio", $bio); | ||
|
||
// Roughly equivalent to: | ||
// `INSERT INTO users (username, bio) VALUES ($1, $2);` | ||
``` | ||
|
||
## $pgInsertSingle.setPlan() | ||
|
||
Returns a `SetterStep` (a "modifier step", rather than an `ExecutableStep`) | ||
that can be useful when combined with `applyPlan` plan resolvers in arguments | ||
and input fields to build up the attributes to set on the inserted row bit by | ||
bit. | ||
|
||
## $pgInsertSingle.get(attr) | ||
|
||
Returns a PgClassExpressionStep representing the given attribute from the | ||
inserted row. This is achieved by selecting the value using the | ||
`INSERT INTO ... RETURNING ...` syntax. | ||
|
||
```ts | ||
const $id = $insertedUser.get("id"); | ||
``` | ||
|
||
## $pgInsertSingle.record() | ||
|
||
Returns a PgClassExpressionStep representing the full record that was inserted. |
Oops, something went wrong.