-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4abf80b
commit cc09e0e
Showing
1 changed file
with
33 additions
and
19 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 |
---|---|---|
@@ -1,40 +1,54 @@ | ||
# Miscellaneous Operations | ||
|
||
### `pgm.sql( sql )` | ||
## Operation `pgm.sql` | ||
|
||
> Run raw sql -- with some optional _[very basic](http://mir.aculo.us/2011/03/09/little-helpers-a-tweet-sized-javascript-templating-engine/)_ mustache templating | ||
#### `pgm.sql( sql )` | ||
|
||
**Arguments:** | ||
> [!IMPORTANT] | ||
> Run raw sql—with some optional | ||
> _[very basic](http://mir.aculo.us/2011/03/09/little-helpers-a-tweet-sized-javascript-templating-engine/)_ mustache templating | ||
- `sql` _[string]_ - SQL query to run | ||
- `args` _[object]_ - (optional) key/val of arguments to replace | ||
### Arguments | ||
|
||
--- | ||
| Name | Type | Description | | ||
|--------|----------|--------------------------------------------------------------------------| | ||
| `sql` | `string` | SQL query to run | | ||
| `args` | `object` | (optional) key/val of arguments to replace in the SQL query (templating) | | ||
|
||
### `pgm.func( sql )` | ||
|
||
> Inserts raw string, which is not escaped | ||
|
||
e.g. `pgm.func('CURRENT_TIMESTAMP')` to use in `default` option for column definition | ||
## Operation `pgm.func` | ||
|
||
#### `pgm.func( sql )` | ||
|
||
**Arguments:** | ||
> [!IMPORTANT] | ||
> Inserts raw string, which is not escaped | ||
> e.g. `pgm.func('CURRENT_TIMESTAMP')` to use in `default` option for column definition | ||
- `sql` _[string]_ - string to not be escaped | ||
### Arguments | ||
|
||
--- | ||
| Name | Type | Description | | ||
|--------|----------|--------------------------| | ||
| `sql` | `string` | String to not be escaped | | ||
|
||
### `pgm.db.query` and `pgm.db.select` | ||
## Operation `pgm.db` | ||
|
||
> Allows to run DB queries with same DB connection migration is running | ||
#### `pgm.db.query` and `pgm.db.select` | ||
|
||
> [!IMPORTANT] | ||
> Allows running DB queries with the same DB connection migration is running | ||
> See [pg.Client.query](https://node-postgres.com/api/client#client-query) | ||
Returns promise with either result of query or returned rows of query (in case of `select`). | ||
Returns promise with either result of query or returned rows of a query (in case of `select`). | ||
|
||
|
||
--- | ||
## Operation `pgm.noTransaction` | ||
|
||
### `pgm.noTransaction` | ||
#### `pgm.noTransaction` | ||
|
||
By default, all migrations are run in one transaction, but some DB operations like add type value (`pgm.addTypeValue`) | ||
does not work if the type is not created in the same transaction. E.g. if it is created in previous migration. You need to | ||
run specific migration outside a transaction (`pgm.noTransaction`). Be aware that this means that you can have | ||
does not work if the type is not created in the same transaction. | ||
E.g., if it is created in previous migration. | ||
You need to run specific migration outside a transaction (`pgm.noTransaction`). | ||
Be aware that this means that you can have | ||
some migrations applied and some not applied, if there is some error during migrating (leading to `ROLLBACK`) |