Comparing version 1.0.23 to 1.0.24
{ | ||
"name": "pg-mem", | ||
"version": "1.0.23", | ||
"version": "1.0.24", | ||
"description": "A memory version of postgres", | ||
@@ -85,2 +85,3 @@ "main": "index.js", | ||
"rimraf": "^3.0.2", | ||
"slonik": "^23.0.1", | ||
"source-map-support": "^0.5.19", | ||
@@ -87,0 +88,0 @@ "style-loader": "^1.2.1", |
@@ -10,2 +10,3 @@ import { LibAdapters, IMemoryDb } from './interfaces'; | ||
createTypeormConnection(postgresOptions: any, queryLatency?: number): any; | ||
createSlonik(queryLatency?: number): any; | ||
createPgPromise(queryLatency?: number): any; | ||
@@ -12,0 +13,0 @@ createPgNative(queryLatency?: number): { |
@@ -87,2 +87,4 @@ import { TableConstraint, CreateColumnDef, StatementLocation } from './parser/syntax/ast'; | ||
createPgPromise(queryLatency?: number): any; | ||
/** Create a slonik pool bound to this db */ | ||
createSlonik(queryLatency?: number): any; | ||
/** Create a pg-native instance bound to this db */ | ||
@@ -89,0 +91,0 @@ createPgNative(queryLatency?: number): any; |
@@ -147,3 +147,15 @@ import { LibAdapters, IMemoryDb, NotSupported, QueryResult } from './interfaces'; | ||
createSlonik(queryLatency?: number) { | ||
const { createMockPool, createMockQueryResult } = __non_webpack_require__('slonik'); | ||
return createMockPool({ | ||
query: async (sql, args) => { | ||
await delay(queryLatency ?? 0); | ||
const formatted = replaceQueryArgs$(sql, args); | ||
const ret = this.db.public.many(formatted); | ||
return createMockQueryResult(ret); | ||
}, | ||
}); | ||
} | ||
createPgPromise(queryLatency?: number) { | ||
@@ -150,0 +162,0 @@ // https://vitaly-t.github.io/pg-promise/module-pg-promise.html |
@@ -99,2 +99,5 @@ import { TableConstraint, CreateColumnDef, StatementLocation } from './parser/syntax/ast'; | ||
/** Create a slonik pool bound to this db */ | ||
createSlonik(queryLatency?: number): any; | ||
/** Create a pg-native instance bound to this db */ | ||
@@ -101,0 +104,0 @@ createPgNative(queryLatency?: number): any; |
@@ -5,4 +5,2 @@ import 'mocha'; | ||
import { expect, assert } from 'chai'; | ||
import { typeormSimpleSample } from '../../samples/typeorm/simple'; | ||
import { typeormJoinsSample } from '../../samples/typeorm/joins'; | ||
import { _IDb } from '../interfaces-private'; | ||
@@ -9,0 +7,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1702594
297
23980
49