TypeScript clients for databases that prevent SQL Injection
MIT License
Bot releases are hidden (Show)
Published by ForbesLindesay over 3 years ago
Published by ForbesLindesay over 3 years ago
Fix typos in help command output (#165)
The parameters must start with --
not -
and there is no --password
parameter for the Postgres utility.
Published by ForbesLindesay over 3 years ago
Fix typo in console.log (#162)
Updaing
-> Updating
Published by ForbesLindesay over 3 years ago
Queryable.addPostCommitStep(fn): Promise<void>
(#167)
If the Queryable is part of a transaction, queue fn
to be called after the top-level transaction is successfully committed.
If the Queryable is not part of a transaction, call fn
immediately and await
the result.
This function can be useful for clearing caches after transactions are committed.
Published by ForbesLindesay over 3 years ago
Fix typos in help command output (#165)
The parameters must start with --
not -
Published by ForbesLindesay over 3 years ago
Queryable.addPostCommitStep(fn): Promise<void>
(#167)
If the Queryable is part of a transaction, queue fn
to be called after the top-level transaction is successfully committed.
If the Queryable is not part of a transaction, call fn
immediately and await
the result.
This function can be useful for clearing caches after transactions are committed.
Published by ForbesLindesay over 3 years ago
transactionParentContext
parameter is passed to the createTransaction
factory and must be passed through to the BaseTransaction
constructor. (#167)Queryable.addPostCommitStep(fn): Promise<void>
(#167)
If the Queryable is part of a transaction, queue fn
to be called after the top-level transaction is successfully committed.
If the Queryable is not part of a transaction, call fn
immediately and await
the result.
This function can be useful for clearing caches after transactions are committed.
Published by ForbesLindesay over 3 years ago
insertOrIgnore
now only returns the successfully inserted rows. It does not include placeholders for values that were not inserted due to conflicts. (#151)
Previously, if you ran:
const results = await my_table().insertOrIgnore({id: 1}, {id: 2})
console.log(results)
with a unique constraint on my_table.id
and a record with id=1
already present in the database, the value of results would have been:
[null, {"id": 2}]
After this update, the value of results
would be:
[{"id": 2}]
The return type of .insert
and .insertOrUpdate
is not impacted by this change.
When multiple records are passed to .insert
, .insertOrIgnore
or .insertOrUpdate
, a single query is now run to insert all the records. (#151)
Previously, if you ran:
await my_table().insert({id: 1}, {id: 2})
It would have produced 2 queries that each looked like:
INSERT INTO my_table (id) VALUES ($1)
The first would have [1]
passed as parameters, and the second would have [2]
passed as parameters.
Now a single query would be run that looks like:
INSERT INTO my_table (id) VALUES ($1), ($2)
This query would be given [1, 2]
as parameters. This is much more efficient for Postgres, especially when creating large numbers of records in one go.
Published by ForbesLindesay over 3 years ago
Update @databases/pg
to 5.0.0 (#150)
Fixes typo in option name
Published by ForbesLindesay over 3 years ago
Update @databases/pg
to 5.0.0 (#150)
Fixes typo in option name
Published by ForbesLindesay over 3 years ago
aquireLockTimeoutMilliseconds
is renamed to acquireLockTimeoutMilliseconds
(#150)Published by ForbesLindesay over 3 years ago
aquireLockTimeoutMilliseconds
is renamed to acquireLockTimeoutMilliseconds
(#150)Published by ForbesLindesay over 3 years ago
aquireLockTimeoutMilliseconds
is renamed to acquireLockTimeoutMilliseconds
(#150)Published by ForbesLindesay over 3 years ago
aquireLock
is now acquireLock
(#150)Published by ForbesLindesay over 3 years ago
You can now select a subset of fields to return when querying (#149)
Usage:
const {users} = pgTyped<DatabaseSchema>()
const userMetadata = await users(database)
.find({active: true})
.select('id', 'name', 'updated_at')
.orderByDesc('updated_at')
.limit(10)
Most of the time there is not much added value in selecting a subset of the fields, but it can be useful if you have database records that contain metadata, along with a very large JSON blob or very large text field. It can be much faster to retrieve only the metadata for large queries.
It can also be useful if you want to avoid retrieving sensitive fields such as password hashes.
Published by ForbesLindesay over 3 years ago
Published by ForbesLindesay over 3 years ago
Published by ForbesLindesay over 3 years ago
Published by ForbesLindesay over 3 years ago
The connection pool implementation has been replaced (#148)
This may introduce some subtle changes, but shouldn't be noticeable for 99% of apps. The advantage is that the new connection pool is part of @databases
so the implementation can be shared between Postgres and MySQL, along with any improvements & optimisations.
Added queueTimeoutMilliseconds
option with default of 60 seconds (#148)
This lets you specify a timeout for how long to wait for a connection from the pool before throwing an error. This may happen if all the connections are in-use by long running queries.
Added aquireLockTimeoutMilliseconds
option with default of 60 seconds (#148)
This is helpful for catching cases where you have accidentally attempted to query a connection within a transaction that is on that connection, or attempted to query an outer transaction within a nested transaction.
Calling .query
with an array of SQLQuery
s inside a transaction no longer implicitly uses savepoints to create a nested transaction (#148)
Calling .query
with a single SQLQuery
that contains multiple statements implicitly wraps the statements in a transaction if not already nested inside a transaction (#148)
Events for onConnectionOpened
and onConnectionClosed
(#148)
These let you track the number of open connections, which can be useful when monitoring the performance of your application.
Published by ForbesLindesay over 3 years ago
Upgrade the underlying driver (i.e. mysql2
) to support MySQL version 8 (#145)
N.B. the default image is still mysql:5.7.24
but you can specify that you would like to test with MySQL 8 by either setting the config value "test": {"image": "mysql:8.0.23"}
or setting the environment variable MYSQL_TEST_IMAGE=mysql:8.0.23