@naturalcycles/db-lib
Advanced tools
Comparing version 2.0.1 to 2.0.2
@@ -0,1 +1,8 @@ | ||
## [2.0.2](https://github.com/NaturalCycles/db-lib/compare/v2.0.1...v2.0.2) (2019-10-19) | ||
### Bug Fixes | ||
* use Readable instead of ReadableStream ([51248c6](https://github.com/NaturalCycles/db-lib/commit/51248c6)) | ||
## [2.0.1](https://github.com/NaturalCycles/db-lib/compare/v2.0.0...v2.0.1) (2019-10-19) | ||
@@ -2,0 +9,0 @@ |
/// <reference types="node" /> | ||
import { IDebugger } from '@naturalcycles/nodejs-lib'; | ||
import { Readable } from 'stream'; | ||
import { CommonDB } from './common.db'; | ||
@@ -55,4 +56,4 @@ import { CommonDBOptions, CommonDBSaveOptions, RunQueryResult, SavedDBEntity } from './db.model'; | ||
runQueryCount(q: DBQuery, opt?: CommonDBOptions): Promise<number>; | ||
streamQuery<DBM extends SavedDBEntity>(q: DBQuery<any, DBM>, opt?: CommonDBSaveOptions): NodeJS.ReadableStream; | ||
streamQuery<DBM extends SavedDBEntity>(q: DBQuery<any, DBM>, opt?: CommonDBSaveOptions): Readable; | ||
deleteByQuery(q: DBQuery, opt?: CommonDBOptions): Promise<number>; | ||
} |
/// <reference types="node" /> | ||
import { Readable } from 'stream'; | ||
import { CommonDBOptions, CommonDBSaveOptions, RunQueryResult, SavedDBEntity } from './db.model'; | ||
@@ -21,3 +22,3 @@ import { DBQuery } from './dbQuery'; | ||
runQueryCount(q: DBQuery, opt?: CommonDBOptions): Promise<number>; | ||
streamQuery<DBM extends SavedDBEntity>(q: DBQuery<any, DBM>, opt?: CommonDBOptions): NodeJS.ReadableStream; | ||
streamQuery<DBM extends SavedDBEntity>(q: DBQuery<any, DBM>, opt?: CommonDBOptions): Readable; | ||
saveBatch<DBM extends SavedDBEntity>(table: string, dbms: DBM[], opt?: CommonDBSaveOptions): Promise<void>; | ||
@@ -24,0 +25,0 @@ /** |
/// <reference types="node" /> | ||
import { Readable } from 'stream'; | ||
import { CommonDBOptions, CommonDBSaveOptions, RunQueryResult, SavedDBEntity } from './db.model'; | ||
@@ -17,4 +18,4 @@ import { DBQuery } from './dbQuery'; | ||
runQueryCount(q: DBQuery, opts?: CommonDBOptions): Promise<number>; | ||
streamQuery<DBM extends SavedDBEntity>(q: DBQuery<any, DBM>, opts?: CommonDBOptions): NodeJS.ReadableStream; | ||
streamQuery<DBM extends SavedDBEntity>(q: DBQuery<any, DBM>, opts?: CommonDBOptions): Readable; | ||
} | ||
export declare function queryInMemory<DBM extends SavedDBEntity, OUT = DBM>(q: DBQuery<any, DBM>, rows?: DBM[]): OUT[]; |
/// <reference types="node" /> | ||
import { Readable } from 'stream'; | ||
import { CommonDB } from './common.db'; | ||
@@ -13,3 +14,3 @@ import { CommonDBOptions, CommonDBSaveOptions, RunQueryResult, SavedDBEntity } from './db.model'; | ||
saveBatch<DBM extends SavedDBEntity>(table: string, dbms: DBM[], opts?: CommonDBSaveOptions): Promise<void>; | ||
streamQuery<OUT>(q: DBQuery, opts?: CommonDBOptions): NodeJS.ReadableStream; | ||
streamQuery<OUT>(q: DBQuery, opts?: CommonDBOptions): Readable; | ||
} |
/// <reference types="node" /> | ||
import { Readable } from 'stream'; | ||
import { CommonDB } from './common.db'; | ||
@@ -27,4 +28,4 @@ import { CommonDBOptions, CommonDBSaveOptions, RunQueryResult, SavedDBEntity } from './db.model'; | ||
runQueryCount(q: DBQuery, opts?: CommonDBOptions): Promise<number>; | ||
streamQuery<DBM extends SavedDBEntity>(q: DBQuery<any, DBM>, opts?: CommonDBOptions): NodeJS.ReadableStream; | ||
streamQuery<DBM extends SavedDBEntity>(q: DBQuery<any, DBM>, opts?: CommonDBOptions): Readable; | ||
deleteByQuery(q: DBQuery, opts?: CommonDBOptions): Promise<number>; | ||
} |
@@ -39,3 +39,3 @@ { | ||
}, | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "Lowest Common Denominator API to supported Databases", | ||
@@ -42,0 +42,0 @@ "keywords": [ |
import { Debug, IDebugger, readableFrom } from '@naturalcycles/nodejs-lib' | ||
import { Readable } from 'stream' | ||
import { CommonDB } from './common.db' | ||
@@ -208,3 +209,3 @@ import { CommonDBOptions, CommonDBSaveOptions, RunQueryResult, SavedDBEntity } from './db.model' | ||
opt: CommonDBSaveOptions = {}, | ||
): NodeJS.ReadableStream { | ||
): Readable { | ||
if (!opt.onlyCache && !this.cfg.onlyCache) { | ||
@@ -211,0 +212,0 @@ const stream = this.cfg.downstreamDB.streamQuery<DBM>(q, opt) |
@@ -0,1 +1,2 @@ | ||
import { Readable } from 'stream' | ||
import { CommonDBOptions, CommonDBSaveOptions, RunQueryResult, SavedDBEntity } from './db.model' | ||
@@ -34,6 +35,3 @@ import { DBQuery } from './dbQuery' | ||
streamQuery<DBM extends SavedDBEntity>( | ||
q: DBQuery<any, DBM>, | ||
opt?: CommonDBOptions, | ||
): NodeJS.ReadableStream | ||
streamQuery<DBM extends SavedDBEntity>(q: DBQuery<any, DBM>, opt?: CommonDBOptions): Readable | ||
@@ -40,0 +38,0 @@ // SAVE |
import { _pick } from '@naturalcycles/js-lib' | ||
import { Debug, readableFrom } from '@naturalcycles/nodejs-lib' | ||
import { Readable } from 'stream' | ||
import { CommonDBOptions, CommonDBSaveOptions, RunQueryResult, SavedDBEntity } from './db.model' | ||
@@ -93,6 +94,3 @@ import { DBQuery, DBQueryFilterOperator } from './dbQuery' | ||
streamQuery<DBM extends SavedDBEntity>( | ||
q: DBQuery<any, DBM>, | ||
opts?: CommonDBOptions, | ||
): NodeJS.ReadableStream { | ||
streamQuery<DBM extends SavedDBEntity>(q: DBQuery<any, DBM>, opts?: CommonDBOptions): Readable { | ||
return readableFrom(queryInMemory<DBM>(q, Object.values(this.data[q.table] || {}))) | ||
@@ -99,0 +97,0 @@ } |
import { readableFrom } from '@naturalcycles/nodejs-lib' | ||
import { Readable } from 'stream' | ||
import { CommonDB } from './common.db' | ||
@@ -39,5 +40,5 @@ import { CommonDBOptions, CommonDBSaveOptions, RunQueryResult, SavedDBEntity } from './db.model' | ||
streamQuery<OUT>(q: DBQuery, opts?: CommonDBOptions): NodeJS.ReadableStream { | ||
streamQuery<OUT>(q: DBQuery, opts?: CommonDBOptions): Readable { | ||
return readableFrom([]) | ||
} | ||
} |
@@ -111,6 +111,3 @@ import * as fs from 'fs-extra' | ||
streamQuery<DBM extends SavedDBEntity>( | ||
q: DBQuery<any, DBM>, | ||
opts?: CommonDBOptions, | ||
): NodeJS.ReadableStream { | ||
streamQuery<DBM extends SavedDBEntity>(q: DBQuery<any, DBM>, opts?: CommonDBOptions): Readable { | ||
const readable = new Readable({ | ||
@@ -117,0 +114,0 @@ objectMode: true, |
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
205796