Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

knexed

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

knexed - npm Package Compare versions

Comparing version 1.3.0 to 1.4.0

catch/constraint.js

8

flow-typed/npm/knex_v0.14.x.js

@@ -5,3 +5,3 @@ // flow-typed signature: 9ce19a0904ee052b819135ea95efe8bc

declare class Knex$Transaction<R>
mixins Knex$QueryBuilder<R>, events$EventEmitter, Promise<R> {
mixins Knex$QueryBuilder<R>, events$EventEmitter, Bluebird$Promise<R>, Promise<R> {
$call: (tableName: string) => Knex$QueryBuilder<R>;

@@ -17,3 +17,3 @@ commit(connection?: any, value?: any): Promise<R>;

declare class Knex$QueryBuilder<R> mixins Promise<R> {
declare class Knex$QueryBuilder<R> mixins Bluebird$Promise<R>, Promise<R> {
clearSelect(): this;

@@ -23,3 +23,3 @@ clearWhere(): this;

select(...key: string[]): this;
timeout(ms: number, options?: { cancel: boolean }): this;
// timeout(ms: number, options?: { cancel: boolean }): this;
column(key: string[]): this;

@@ -158,3 +158,3 @@ column(...key: string[]): this;

declare class Knex$Knex<R>
mixins Knex$QueryBuilder<R>, Promise<R>, events$EventEmitter {
mixins Knex$QueryBuilder<R>, Bluebird$Promise<R>, Promise<R>, events$EventEmitter {
static (config: Knex$Config): Knex$Knex<R>;

@@ -161,0 +161,0 @@ static QueryBuilder: typeof Knex$QueryBuilder;

@@ -1,2 +0,2 @@

Copyright © 2016 — 2017 Strider.
Copyright © 2018 Strider.
https://github.com/StreetStrider

@@ -3,0 +3,0 @@

{
"name": "knexed",
"version": "1.3.0",
"version": "1.4.0",

@@ -23,3 +23,3 @@ "description": "Knex utilities",

{
"node": ">= 4"
"node": ">= 5"
},

@@ -37,6 +37,6 @@

"mocha": "mocha --check-leaks --recursive test/**.test.js test/**/*.test.js",
"unit": "mocha --check-leaks --recursive test/**.test.js test/**/*.test.js",
"cover": "istanbul cover _mocha -- --check-leaks --recursive test/**.test.js test/**/*.test.js",
"test": "npm run st && npm run t && npm run mocha",
"test": "npm run st && npm run t && npm run unit",
"all": "npm test && npm run cover",

@@ -47,2 +47,7 @@

"dependencies":
{
"bluebird": "3"
},
"devDependencies":

@@ -49,0 +54,0 @@ {

@@ -9,3 +9,3 @@ /* @flow */

module.exports = function count (query /* :$QueryBuilder<any> */)
/* :Promise<number> */
/* :Bluebird$Promise<number> */
{

@@ -12,0 +12,0 @@ return query.count('* as count')

@@ -9,3 +9,3 @@ /* @flow */

module.exports = function exists (query /* :$QueryBuilder<any> */)
/* :Promise<boolean> */
/* :Bluebird$Promise<boolean> */
{

@@ -12,0 +12,0 @@ var client = query.client

@@ -56,3 +56,3 @@ # knexed

{
return accounts(trx).insert({ name: name })
return accounts(trx).insert({ name })
})

@@ -124,2 +124,53 @@

### catch constraints (`catch/constraint`)
Catch constraints and rethrow them as your model-specific constraint errors.
```js
var accounts = table(knex, 'accounts')
function AlreadyExists ()
{
return new TypeError('account_already_exists')
}
accounts()
.insert({ id: 1, name: 'account' })
.catch(...catch_constraint({ constraint: 'accounts_pkey' }, AlreadyExists))
```
```js
var accounts = table(knex, 'accounts')
function AlreadyExists (data)
{
return { error: 'account_already_exists', conflict: data }
}
var id = 1
accounts()
.insert({ id, name: 'account' })
.catch(...catch_constraint({ constraint: 'accounts_pkey' }, { id }, AlreadyExists))
```
### guarantee proper updates & deletes (`updated`)
Will throw is zero or more than one row had been updated.
```js
var accounts = table(knex, 'accounts')
/* preventing too many (or zero) rows deletion */
accounts()
.delete()
.then(updated)
```
```js
var accounts = table(knex, 'accounts')
/* guarantee one and only one row modification */
accounts()
.where('name', 'not found')
.update('name', 'Not Found')
.then(updated)
```
## flow

@@ -130,2 +181,2 @@ We're providing built-in [Flow](https://flowtype.org/) type definitions.

MIT.
© Strider, 2016 — 2017.
© Strider, 2016 — 2018.

@@ -12,8 +12,11 @@ /* @flow */

export type RetPromise<T>
= ( ...args: Array<any>) => Promise<T>
export type $Async<T>
= (...args: Array<any>) => Bluebird$Promise<T>
export type TxRetPromise<T>
= (tx: Knex$Transaction<T>, ...args: Array<any>) => Promise<T>
export type $Async$Tx<T>
= (tx: Knex$Transaction<T>, ...args: Array<any>) => $Promisable<T>
export type $Async$Tx$Strict<T>
= (tx: Knex$Transaction<T>, ...args: Array<any>) => Bluebird$Promise<T>
*/

@@ -25,2 +28,4 @@

var bmethod = require('bluebird').method
var method

@@ -31,6 +36,8 @@ = module.exports

kx /* :Knex */,
fn /* :TxRetPromise<T> */
fn /* :$Async$Tx<T> */
)
/* :RetPromise<T> */
/* :$Async<T> */
{
var fn$ /* :$Async$Tx$Strict<T> */ = bmethod(fn)
return function

@@ -41,11 +48,11 @@ (

)
/* :Promise<T> */
/* :Bluebird$Promise<T> */
{
if (is(tx))
{
return fn.apply(this, arguments)
return fn$.apply(this, arguments)
}
else if (tx === NOTX)
{
return fn.apply(this, arguments)
return fn$.apply(this, arguments)
}

@@ -58,3 +65,3 @@ else

{
return fn.apply(this, [ tx ].concat(args))
return fn$.apply(this, [ tx ].concat(args))
})

@@ -61,0 +68,0 @@ }

@@ -20,3 +20,3 @@ /* @flow */

{
key: (id) => ({ id: id }),
key: (id) => ({ id }),
}

@@ -23,0 +23,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc