@keyv/postgres
Advanced tools
Comparing version 1.2.1 to 1.3.0
{ | ||
"name": "@keyv/postgres", | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"description": "PostgreSQL storage adapter for Keyv", | ||
@@ -14,3 +14,12 @@ "main": "src/index.js", | ||
"unicorn/prefer-module": 0, | ||
"unicorn/prefer-node-protocol": 0 | ||
"unicorn/prefer-node-protocol": 0, | ||
"ava/no-ignored-test-files": [ | ||
"error", | ||
{ | ||
"extensions": [ | ||
"js", | ||
"ts" | ||
] | ||
} | ||
] | ||
} | ||
@@ -20,3 +29,8 @@ }, | ||
"require": [ | ||
"requirable" | ||
"requirable", | ||
"ts-node/register" | ||
], | ||
"extensions": [ | ||
"js", | ||
"ts" | ||
] | ||
@@ -52,13 +66,15 @@ }, | ||
"@keyv/test-suite": "*", | ||
"ava": "^4.0.1", | ||
"ava": "^4.3.1", | ||
"keyv": "*", | ||
"@types/keyv": "^3.1.4", | ||
"nyc": "^15.1.0", | ||
"requirable": "^1.0.5", | ||
"this": "^1.1.0", | ||
"tsd": "^0.19.1", | ||
"typescript": "^4.6.2", | ||
"xo": "^0.48.0" | ||
"tsd": "^0.22.0", | ||
"ts-node": "^10.9.1", | ||
"typescript": "^4.7.4", | ||
"xo": "^0.51.0" | ||
}, | ||
"tsd" : { | ||
"directory" : "test" | ||
"tsd": { | ||
"directory": "test" | ||
}, | ||
@@ -65,0 +81,0 @@ "types": "./src/index.d.ts", |
@@ -6,4 +6,5 @@ # @keyv/postgres [<img width="100" align="right" src="https://rawgit.com/lukechilds/keyv/master/media/logo.svg" alt="keyv">](https://github.com/lukechilds/keyv) | ||
[![build](https://github.com/jaredwray/keyv/actions/workflows/tests.yaml/badge.svg)](https://github.com/jaredwray/keyv/actions/workflows/btestsuild.yaml) | ||
[![codecov](https://codecov.io/gh/jaredwray/keyv/branch/master/graph/badge.svg?token=bRzR3RyOXZ)](https://codecov.io/gh/jaredwray/keyv) | ||
[![codecov](https://codecov.io/gh/jaredwray/keyv/branch/main/graph/badge.svg?token=bRzR3RyOXZ)](https://codecov.io/gh/jaredwray/keyv) | ||
[![npm](https://img.shields.io/npm/v/@keyv/postgres.svg)](https://www.npmjs.com/package/@keyv/postgres) | ||
[![npm](https://img.shields.io/npm/dm/@keyv/postgres)](https://npmjs.com/package/@keyv/postgres) | ||
@@ -55,2 +56,2 @@ PostgreSQL storage adapter for [Keyv](https://github.com/lukechilds/keyv). | ||
MIT © Jared Wray & Luke Childs | ||
MIT © Jared Wray |
import {EventEmitter} from 'events'; | ||
import {Store, StoredData} from 'keyv'; | ||
export = KeyvPostgres; | ||
declare class KeyvPostgres extends EventEmitter { | ||
declare class KeyvPostgres extends EventEmitter implements Store<Value> { | ||
readonly ttlSupport: false; | ||
@@ -9,10 +10,12 @@ opts: any; | ||
constructor(options?: string | KeyvPostgres.Options); | ||
get(key: string): Promise<string | undefined>; | ||
getMany(keys: string[]): Promise<string[] | undefined>; | ||
set(key: string, value: string | undefined): Promise<any>; | ||
delete(key: string): boolean; | ||
get(key: string): Promise<Value>; | ||
getMany?( | ||
keys: string[] | ||
): Array<StoredData<Value>> | Promise<Array<StoredData<Value>>> | undefined; | ||
set(key: string, value: Value, ttl?: number): any; | ||
delete(key: string): boolean | Promise<boolean>; | ||
deleteMany(keys: string[]): boolean; | ||
clear(): Promise<void>; | ||
clear(): void | Promise<void>; | ||
iterator(namespace: string | undefined): AsyncGenerator<any, void, any>; | ||
has(key: string): boolean; | ||
has?(key: string): boolean | Promise<boolean>; | ||
} | ||
@@ -19,0 +22,0 @@ declare namespace KeyvPostgres { |
'use strict'; | ||
const EventEmitter = require('events'); | ||
const {pool} = require('./pool.js'); | ||
const {pool, endPool} = require('./pool.js'); | ||
@@ -48,6 +48,2 @@ class KeyvPostgres extends EventEmitter { | ||
return this.query(getMany, [keys]).then(rows => { | ||
if (rows.length === 0) { | ||
return []; | ||
} | ||
const results = [...keys]; | ||
@@ -129,5 +125,3 @@ let i = 0; | ||
if (offset !== 0) { | ||
yield * iterate(offset, options, query); | ||
} | ||
yield * iterate(offset, options, query); | ||
} | ||
@@ -142,4 +136,8 @@ | ||
} | ||
disconnect() { | ||
return endPool(); | ||
} | ||
} | ||
module.exports = KeyvPostgres; |
@@ -16,4 +16,10 @@ const {Pool} = require('pg'); | ||
const endPool = () => { | ||
pool.end(); | ||
globalUri = undefined; | ||
}; | ||
module.exports = { | ||
pool: uri => pools(uri), | ||
endPool, | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8104
161
56
11