@naturalcycles/db-lib
Advanced tools
Comparing version 1.23.0 to 1.23.1
@@ -0,1 +1,8 @@ | ||
## [1.23.1](https://github.com/NaturalCycles/db-lib/compare/v1.23.0...v1.23.1) (2019-09-21) | ||
### Bug Fixes | ||
* change DBM/BM order, again ([ff388d2](https://github.com/NaturalCycles/db-lib/commit/ff388d2)) | ||
# [1.23.0](https://github.com/NaturalCycles/db-lib/compare/v1.22.0...v1.23.0) (2019-09-21) | ||
@@ -2,0 +9,0 @@ |
@@ -53,6 +53,6 @@ import { IDebugger } from '@naturalcycles/nodejs-lib'; | ||
saveBatch<DBM extends SavedDBEntity>(table: string, dbms: DBM[], opts?: CommonDBSaveOptions): Promise<void>; | ||
runQuery<DBM extends SavedDBEntity, OUT = DBM>(q: DBQuery<DBM>, opts?: CommonDBOptions): Promise<RunQueryResult<OUT>>; | ||
runQuery<DBM extends SavedDBEntity, OUT = DBM>(q: DBQuery<any, DBM>, opts?: CommonDBOptions): Promise<RunQueryResult<OUT>>; | ||
runQueryCount(q: DBQuery, opts?: CommonDBOptions): Promise<number>; | ||
streamQuery<DBM extends SavedDBEntity, OUT = DBM>(q: DBQuery<DBM>, opts?: CommonDBSaveOptions): Observable<OUT>; | ||
streamQuery<DBM extends SavedDBEntity, OUT = DBM>(q: DBQuery<any, DBM>, opts?: CommonDBSaveOptions): Observable<OUT>; | ||
deleteByQuery(q: DBQuery, opts?: CommonDBOptions): Promise<number>; | ||
} |
import { JoiValidationError, ObjectSchemaTyped } from '@naturalcycles/nodejs-lib'; | ||
import { Observable } from 'rxjs'; | ||
import { CommonDB } from './common.db'; | ||
import { BaseDBEntity, CommonDaoOptions, CommonDaoSaveOptions, DBModelType, RunQueryResult, Saved, SavedDBEntity, Unsaved } from './db.model'; | ||
import { BaseDBEntity, CommonDaoOptions, CommonDaoSaveOptions, DBModelType, RunQueryResult, Saved, SavedDBEntity } from './db.model'; | ||
import { DBQuery, RunnableDBQuery } from './dbQuery'; | ||
@@ -15,3 +15,3 @@ export declare enum CommonDaoLogLevel { | ||
} | ||
export interface CommonDaoCfg<DBM extends SavedDBEntity, BM extends BaseDBEntity, TM> { | ||
export interface CommonDaoCfg<BM extends BaseDBEntity, DBM extends SavedDBEntity, TM> { | ||
db: CommonDB; | ||
@@ -49,5 +49,5 @@ table: string; | ||
*/ | ||
export declare class CommonDao<DBM extends SavedDBEntity = any, BM extends BaseDBEntity = Unsaved<DBM>, TM = BM> { | ||
cfg: CommonDaoCfg<DBM, BM, TM>; | ||
constructor(cfg: CommonDaoCfg<DBM, BM, TM>); | ||
export declare class CommonDao<BM extends BaseDBEntity = any, DBM extends SavedDBEntity = Saved<BM>, TM = BM> { | ||
cfg: CommonDaoCfg<BM, DBM, TM>; | ||
constructor(cfg: CommonDaoCfg<BM, DBM, TM>); | ||
/** | ||
@@ -100,12 +100,12 @@ * To be extended | ||
getAll(opt?: CommonDaoOptions): Promise<Saved<BM>[]>; | ||
query(name?: string): RunnableDBQuery<DBM, BM, TM>; | ||
runQuery<OUT = Saved<BM>>(q: DBQuery<DBM, BM, TM>, opt?: CommonDaoOptions): Promise<OUT[]>; | ||
runQueryExtended<OUT = Saved<BM>>(q: DBQuery<DBM, BM, TM>, opt?: CommonDaoOptions): Promise<RunQueryResult<OUT>>; | ||
runQueryAsDBM<OUT = DBM>(q: DBQuery<DBM>, opt?: CommonDaoOptions): Promise<OUT[]>; | ||
runQueryExtendedAsDBM<OUT = DBM>(q: DBQuery<DBM, BM, TM>, opt?: CommonDaoOptions): Promise<RunQueryResult<OUT>>; | ||
runQueryCount(q: DBQuery<DBM, BM, TM>, opt?: CommonDaoOptions): Promise<number>; | ||
streamQuery<OUT = Saved<BM>>(q: DBQuery<DBM, BM, TM>, opt?: CommonDaoOptions): Observable<OUT>; | ||
streamQueryAsDBM<OUT = DBM>(q: DBQuery<DBM, BM, TM>, opt?: CommonDaoOptions): Observable<OUT>; | ||
queryIds(q: DBQuery<DBM>, opt?: CommonDaoOptions): Promise<string[]>; | ||
streamQueryIds(q: DBQuery<DBM>, opt?: CommonDaoOptions): Observable<string>; | ||
query(name?: string): RunnableDBQuery<BM, DBM, TM>; | ||
runQuery<OUT = Saved<BM>>(q: DBQuery<BM, DBM, TM>, opt?: CommonDaoOptions): Promise<OUT[]>; | ||
runQueryExtended<OUT = Saved<BM>>(q: DBQuery<BM, DBM, TM>, opt?: CommonDaoOptions): Promise<RunQueryResult<OUT>>; | ||
runQueryAsDBM<OUT = DBM>(q: DBQuery<BM, DBM>, opt?: CommonDaoOptions): Promise<OUT[]>; | ||
runQueryExtendedAsDBM<OUT = DBM>(q: DBQuery<BM, DBM, TM>, opt?: CommonDaoOptions): Promise<RunQueryResult<OUT>>; | ||
runQueryCount(q: DBQuery<BM, DBM, TM>, opt?: CommonDaoOptions): Promise<number>; | ||
streamQuery<OUT = Saved<BM>>(q: DBQuery<BM, DBM, TM>, opt?: CommonDaoOptions): Observable<OUT>; | ||
streamQueryAsDBM<OUT = DBM>(q: DBQuery<BM, DBM, TM>, opt?: CommonDaoOptions): Observable<OUT>; | ||
queryIds(q: DBQuery<BM, DBM>, opt?: CommonDaoOptions): Promise<string[]>; | ||
streamQueryIds(q: DBQuery<BM, DBM>, opt?: CommonDaoOptions): Observable<string>; | ||
assignIdCreatedUpdated<T extends DBM | BM>(obj: T, opt?: CommonDaoOptions): Saved<T>; | ||
@@ -112,0 +112,0 @@ save(bm: BM, opt?: CommonDaoSaveOptions): Promise<Saved<BM>>; |
@@ -19,5 +19,5 @@ import { Observable } from 'rxjs'; | ||
*/ | ||
runQuery<DBM extends SavedDBEntity, OUT = DBM>(q: DBQuery<DBM>, opt?: CommonDBOptions): Promise<RunQueryResult<OUT>>; | ||
runQuery<DBM extends SavedDBEntity, OUT = DBM>(q: DBQuery<any, DBM>, opt?: CommonDBOptions): Promise<RunQueryResult<OUT>>; | ||
runQueryCount(q: DBQuery, opt?: CommonDBOptions): Promise<number>; | ||
streamQuery<DBM extends SavedDBEntity, OUT = DBM>(q: DBQuery<DBM>, opt?: CommonDBOptions): Observable<OUT>; | ||
streamQuery<DBM extends SavedDBEntity, OUT = DBM>(q: DBQuery<any, DBM>, opt?: CommonDBOptions): Observable<OUT>; | ||
saveBatch<DBM extends SavedDBEntity>(table: string, dbms: DBM[], opt?: CommonDBSaveOptions): Promise<void>; | ||
@@ -24,0 +24,0 @@ /** |
import { Observable } from 'rxjs'; | ||
import { CommonDao } from './common.dao'; | ||
import { BaseDBEntity, CommonDaoOptions, RunQueryResult, Saved, SavedDBEntity, Unsaved } from './db.model'; | ||
import { BaseDBEntity, CommonDaoOptions, RunQueryResult, Saved, SavedDBEntity } from './db.model'; | ||
export declare type DBQueryFilterOperator = '<' | '<=' | '=' | '>=' | '>' | 'in'; | ||
@@ -24,3 +24,3 @@ export interface DBQueryFilter { | ||
*/ | ||
export declare class DBQuery<DBM extends SavedDBEntity = any, BM extends BaseDBEntity = Unsaved<DBM>, TM = BM> { | ||
export declare class DBQuery<BM extends BaseDBEntity = any, DBM extends SavedDBEntity = Saved<BM>, TM = BM> { | ||
table: string; | ||
@@ -46,3 +46,3 @@ name?: string | undefined; | ||
endCursor(endCursor?: string): this; | ||
clone(): DBQuery<DBM, BM, TM>; | ||
clone(): DBQuery<BM, DBM, TM>; | ||
pretty(): string; | ||
@@ -54,5 +54,5 @@ prettyConditions(): string[]; | ||
*/ | ||
export declare class RunnableDBQuery<DBM extends SavedDBEntity = any, BM extends BaseDBEntity = Unsaved<DBM>, TM = BM> extends DBQuery<DBM, BM, TM> { | ||
dao: CommonDao<DBM, BM, TM>; | ||
constructor(dao: CommonDao<DBM, BM, TM>, name?: string); | ||
export declare class RunnableDBQuery<BM extends BaseDBEntity = any, DBM extends SavedDBEntity = Saved<BM>, TM = BM> extends DBQuery<BM, DBM, TM> { | ||
dao: CommonDao<BM, DBM, TM>; | ||
constructor(dao: CommonDao<BM, DBM, TM>, name?: string); | ||
runQuery<OUT = Saved<BM>>(opt?: CommonDaoOptions): Promise<OUT[]>; | ||
@@ -59,0 +59,0 @@ runQueryAsDBM<OUT = DBM>(opt?: CommonDaoOptions): Promise<OUT[]>; |
@@ -14,7 +14,7 @@ import { Observable } from 'rxjs'; | ||
deleteByIds(table: string, ids: string[], opts?: CommonDBOptions): Promise<number>; | ||
deleteByQuery<DBM extends SavedDBEntity>(q: DBQuery<DBM>, opts?: CommonDBOptions): Promise<number>; | ||
runQuery<DBM extends SavedDBEntity, OUT = DBM>(q: DBQuery<DBM>, opts?: CommonDBOptions): Promise<RunQueryResult<OUT>>; | ||
deleteByQuery<DBM extends SavedDBEntity>(q: DBQuery<any, DBM>, opts?: CommonDBOptions): Promise<number>; | ||
runQuery<DBM extends SavedDBEntity, OUT = DBM>(q: DBQuery<any, DBM>, opts?: CommonDBOptions): Promise<RunQueryResult<OUT>>; | ||
runQueryCount(q: DBQuery, opts?: CommonDBOptions): Promise<number>; | ||
streamQuery<DBM extends SavedDBEntity, OUT = DBM>(q: DBQuery<DBM>, opts?: CommonDBOptions): Observable<OUT>; | ||
streamQuery<DBM extends SavedDBEntity, OUT = DBM>(q: DBQuery<any, DBM>, opts?: CommonDBOptions): Observable<OUT>; | ||
} | ||
export declare function queryInMemory<DBM extends SavedDBEntity, OUT = DBM>(q: DBQuery<DBM>, rows?: DBM[]): OUT[]; | ||
export declare function queryInMemory<DBM extends SavedDBEntity, OUT = DBM>(q: DBQuery<any, DBM>, rows?: DBM[]): OUT[]; |
@@ -25,6 +25,6 @@ import { Observable } from 'rxjs'; | ||
saveBatch<DBM extends SavedDBEntity>(table: string, dbms: DBM[], opts?: CommonDBSaveOptions): Promise<void>; | ||
runQuery<DBM extends SavedDBEntity, OUT = DBM>(q: DBQuery<DBM>, opts?: CommonDBOptions): Promise<RunQueryResult<OUT>>; | ||
runQuery<DBM extends SavedDBEntity, OUT = DBM>(q: DBQuery<any, DBM>, opts?: CommonDBOptions): Promise<RunQueryResult<OUT>>; | ||
runQueryCount(q: DBQuery, opts?: CommonDBOptions): Promise<number>; | ||
streamQuery<DBM extends SavedDBEntity, OUT = DBM>(q: DBQuery<DBM>, opts?: CommonDBOptions): Observable<OUT>; | ||
streamQuery<DBM extends SavedDBEntity, OUT = DBM>(q: DBQuery<any, DBM>, opts?: CommonDBOptions): Observable<OUT>; | ||
deleteByQuery(q: DBQuery, opts?: CommonDBOptions): Promise<number>; | ||
} |
@@ -37,3 +37,3 @@ { | ||
}, | ||
"version": "1.23.0", | ||
"version": "1.23.1", | ||
"description": "Lowest Common Denominator API to supported Databases", | ||
@@ -40,0 +40,0 @@ "keywords": [ |
@@ -164,3 +164,3 @@ import { Debug, IDebugger } from '@naturalcycles/nodejs-lib' | ||
async runQuery<DBM extends SavedDBEntity, OUT = DBM>( | ||
q: DBQuery<DBM>, | ||
q: DBQuery<any, DBM>, | ||
opts: CommonDBOptions = {}, | ||
@@ -209,3 +209,3 @@ ): Promise<RunQueryResult<OUT>> { | ||
streamQuery<DBM extends SavedDBEntity, OUT = DBM>( | ||
q: DBQuery<DBM>, | ||
q: DBQuery<any, DBM>, | ||
opts: CommonDBSaveOptions = {}, | ||
@@ -212,0 +212,0 @@ ): Observable<OUT> { |
@@ -21,3 +21,2 @@ import { | ||
SavedDBEntity, | ||
Unsaved, | ||
} from './db.model' | ||
@@ -36,3 +35,3 @@ import { DBQuery, RunnableDBQuery } from './dbQuery' | ||
export interface CommonDaoCfg<DBM extends SavedDBEntity, BM extends BaseDBEntity, TM> { | ||
export interface CommonDaoCfg<BM extends BaseDBEntity, DBM extends SavedDBEntity, TM> { | ||
db: CommonDB | ||
@@ -79,7 +78,7 @@ table: string | ||
export class CommonDao< | ||
DBM extends SavedDBEntity = any, | ||
BM extends BaseDBEntity = Unsaved<DBM>, | ||
BM extends BaseDBEntity = any, | ||
DBM extends SavedDBEntity = Saved<BM>, | ||
TM = BM | ||
> { | ||
constructor(public cfg: CommonDaoCfg<DBM, BM, TM>) { | ||
constructor(public cfg: CommonDaoCfg<BM, DBM, TM>) { | ||
this.cfg = { | ||
@@ -248,7 +247,7 @@ logLevel: CommonDaoLogLevel.OPERATIONS, | ||
// QUERY | ||
query(name?: string): RunnableDBQuery<DBM, BM, TM> { | ||
return new RunnableDBQuery<DBM, BM, TM>(this, name) | ||
query(name?: string): RunnableDBQuery<BM, DBM, TM> { | ||
return new RunnableDBQuery<BM, DBM, TM>(this, name) | ||
} | ||
async runQuery<OUT = Saved<BM>>(q: DBQuery<DBM, BM, TM>, opt?: CommonDaoOptions): Promise<OUT[]> { | ||
async runQuery<OUT = Saved<BM>>(q: DBQuery<BM, DBM, TM>, opt?: CommonDaoOptions): Promise<OUT[]> { | ||
const { records } = await this.runQueryExtended<OUT>(q, opt) | ||
@@ -259,3 +258,3 @@ return records | ||
async runQueryExtended<OUT = Saved<BM>>( | ||
q: DBQuery<DBM, BM, TM>, | ||
q: DBQuery<BM, DBM, TM>, | ||
opt?: CommonDaoOptions, | ||
@@ -275,3 +274,3 @@ ): Promise<RunQueryResult<OUT>> { | ||
async runQueryAsDBM<OUT = DBM>(q: DBQuery<DBM>, opt?: CommonDaoOptions): Promise<OUT[]> { | ||
async runQueryAsDBM<OUT = DBM>(q: DBQuery<BM, DBM>, opt?: CommonDaoOptions): Promise<OUT[]> { | ||
const { records } = await this.runQueryExtendedAsDBM<OUT>(q, opt) | ||
@@ -282,3 +281,3 @@ return records | ||
async runQueryExtendedAsDBM<OUT = DBM>( | ||
q: DBQuery<DBM, BM, TM>, | ||
q: DBQuery<BM, DBM, TM>, | ||
opt?: CommonDaoOptions, | ||
@@ -295,3 +294,3 @@ ): Promise<RunQueryResult<OUT>> { | ||
async runQueryCount(q: DBQuery<DBM, BM, TM>, opt?: CommonDaoOptions): Promise<number> { | ||
async runQueryCount(q: DBQuery<BM, DBM, TM>, opt?: CommonDaoOptions): Promise<number> { | ||
const op = `runQueryCount(${q.pretty()})` | ||
@@ -306,3 +305,3 @@ const started = this.logStarted(op) | ||
streamQuery<OUT = Saved<BM>>(q: DBQuery<DBM, BM, TM>, opt?: CommonDaoOptions): Observable<OUT> { | ||
streamQuery<OUT = Saved<BM>>(q: DBQuery<BM, DBM, TM>, opt?: CommonDaoOptions): Observable<OUT> { | ||
const op = `streamQuery(${q.pretty()})` | ||
@@ -331,3 +330,3 @@ const started = this.logStarted(op, true) | ||
streamQueryAsDBM<OUT = DBM>(q: DBQuery<DBM, BM, TM>, opt?: CommonDaoOptions): Observable<OUT> { | ||
streamQueryAsDBM<OUT = DBM>(q: DBQuery<BM, DBM, TM>, opt?: CommonDaoOptions): Observable<OUT> { | ||
const op = `streamQueryAsDBM(${q.pretty()})` | ||
@@ -356,3 +355,3 @@ const started = this.logStarted(op, true) | ||
async queryIds(q: DBQuery<DBM>, opt?: CommonDaoOptions): Promise<string[]> { | ||
async queryIds(q: DBQuery<BM, DBM>, opt?: CommonDaoOptions): Promise<string[]> { | ||
const { records } = await this.cfg.db.runQuery<DBM, ObjectWithId>(q.select(['id']), opt) | ||
@@ -362,3 +361,3 @@ return records.map(r => r.id) | ||
streamQueryIds(q: DBQuery<DBM>, opt?: CommonDaoOptions): Observable<string> { | ||
streamQueryIds(q: DBQuery<BM, DBM>, opt?: CommonDaoOptions): Observable<string> { | ||
return this.cfg.db | ||
@@ -365,0 +364,0 @@ .streamQuery<DBM, ObjectWithId>(q.select(['id']), opt) |
@@ -29,3 +29,3 @@ import { Observable } from 'rxjs' | ||
runQuery<DBM extends SavedDBEntity, OUT = DBM>( | ||
q: DBQuery<DBM>, | ||
q: DBQuery<any, DBM>, | ||
opt?: CommonDBOptions, | ||
@@ -37,3 +37,3 @@ ): Promise<RunQueryResult<OUT>> | ||
streamQuery<DBM extends SavedDBEntity, OUT = DBM>( | ||
q: DBQuery<DBM>, | ||
q: DBQuery<any, DBM>, | ||
opt?: CommonDBOptions, | ||
@@ -40,0 +40,0 @@ ): Observable<OUT> |
import { _truncate } from '@naturalcycles/js-lib' | ||
import { Observable } from 'rxjs' | ||
import { CommonDao } from './common.dao' | ||
import { | ||
BaseDBEntity, | ||
CommonDaoOptions, | ||
RunQueryResult, | ||
Saved, | ||
SavedDBEntity, | ||
Unsaved, | ||
} from './db.model' | ||
import { BaseDBEntity, CommonDaoOptions, RunQueryResult, Saved, SavedDBEntity } from './db.model' | ||
@@ -49,4 +42,4 @@ export type DBQueryFilterOperator = '<' | '<=' | '=' | '>=' | '>' | 'in' | ||
export class DBQuery< | ||
DBM extends SavedDBEntity = any, | ||
BM extends BaseDBEntity = Unsaved<DBM>, | ||
BM extends BaseDBEntity = any, | ||
DBM extends SavedDBEntity = Saved<BM>, | ||
TM = BM | ||
@@ -107,4 +100,4 @@ > { | ||
clone(): DBQuery<DBM, BM, TM> { | ||
return Object.assign(new DBQuery<DBM, BM, TM>(this.table), { | ||
clone(): DBQuery<BM, DBM, TM> { | ||
return Object.assign(new DBQuery<BM, DBM, TM>(this.table), { | ||
_filters: [...this._filters], | ||
@@ -158,7 +151,7 @@ _limitValue: this._limitValue, | ||
export class RunnableDBQuery< | ||
DBM extends SavedDBEntity = any, | ||
BM extends BaseDBEntity = Unsaved<DBM>, | ||
BM extends BaseDBEntity = any, | ||
DBM extends SavedDBEntity = Saved<BM>, | ||
TM = BM | ||
> extends DBQuery<DBM, BM, TM> { | ||
constructor(public dao: CommonDao<DBM, BM, TM>, name?: string) { | ||
> extends DBQuery<BM, DBM, TM> { | ||
constructor(public dao: CommonDao<BM, DBM, TM>, name?: string) { | ||
super(dao.cfg.table, name) | ||
@@ -165,0 +158,0 @@ } |
@@ -75,3 +75,3 @@ import { _pick } from '@naturalcycles/js-lib' | ||
async deleteByQuery<DBM extends SavedDBEntity>( | ||
q: DBQuery<DBM>, | ||
q: DBQuery<any, DBM>, | ||
opts?: CommonDBOptions, | ||
@@ -85,3 +85,3 @@ ): Promise<number> { | ||
async runQuery<DBM extends SavedDBEntity, OUT = DBM>( | ||
q: DBQuery<DBM>, | ||
q: DBQuery<any, DBM>, | ||
opts?: CommonDBOptions, | ||
@@ -97,3 +97,3 @@ ): Promise<RunQueryResult<OUT>> { | ||
streamQuery<DBM extends SavedDBEntity, OUT = DBM>( | ||
q: DBQuery<DBM>, | ||
q: DBQuery<any, DBM>, | ||
opts?: CommonDBOptions, | ||
@@ -106,3 +106,3 @@ ): Observable<OUT> { | ||
export function queryInMemory<DBM extends SavedDBEntity, OUT = DBM>( | ||
q: DBQuery<DBM>, | ||
q: DBQuery<any, DBM>, | ||
rows: DBM[] = [], | ||
@@ -109,0 +109,0 @@ ): OUT[] { |
@@ -100,3 +100,3 @@ import * as fs from 'fs-extra' | ||
async runQuery<DBM extends SavedDBEntity, OUT = DBM>( | ||
q: DBQuery<DBM>, | ||
q: DBQuery<any, DBM>, | ||
opts?: CommonDBOptions, | ||
@@ -113,3 +113,3 @@ ): Promise<RunQueryResult<OUT>> { | ||
streamQuery<DBM extends SavedDBEntity, OUT = DBM>( | ||
q: DBQuery<DBM>, | ||
q: DBQuery<any, DBM>, | ||
opts?: CommonDBOptions, | ||
@@ -116,0 +116,0 @@ ): Observable<OUT> { |
@@ -5,3 +5,3 @@ import { _pick, _sortBy, pDelay } from '@naturalcycles/js-lib' | ||
import { DBQuery } from '../dbQuery' | ||
import { createTestItemsDBM, TEST_TABLE, TestItemDBM } from './test.model' | ||
import { createTestItemsDBM, TEST_TABLE, TestItemBM, TestItemDBM } from './test.model' | ||
import { deepFreeze } from './test.util' | ||
@@ -36,3 +36,3 @@ | ||
const queryAll = () => new DBQuery<TestItemDBM>(TEST_TABLE, 'all') | ||
const queryAll = () => new DBQuery<TestItemBM, TestItemDBM>(TEST_TABLE, 'all') | ||
@@ -88,3 +88,7 @@ // DELETE ALL initially | ||
test('query even=true', async () => { | ||
const q = new DBQuery<TestItemDBM>(TEST_TABLE, 'only even').filter('even', '=', true) | ||
const q = new DBQuery<TestItemBM, TestItemDBM>(TEST_TABLE, 'only even').filter( | ||
'even', | ||
'=', | ||
true, | ||
) | ||
let { records } = await db.runQuery(q) | ||
@@ -97,3 +101,3 @@ if (allowQueryUnsorted) records = _sortBy(records, 'id') | ||
test('query order by k1 desc', async () => { | ||
const q = new DBQuery<TestItemDBM>(TEST_TABLE, 'desc').order('k1', true) | ||
const q = new DBQuery<TestItemBM, TestItemDBM>(TEST_TABLE, 'desc').order('k1', true) | ||
const { records } = await db.runQuery(q) | ||
@@ -105,3 +109,3 @@ expect(records).toEqual([...items].reverse()) | ||
test('projection query with only ids', async () => { | ||
const q = new DBQuery<TestItemDBM>(TEST_TABLE).select([]) | ||
const q = new DBQuery<TestItemBM, TestItemDBM>(TEST_TABLE).select([]) | ||
let { records } = await db.runQuery(q) | ||
@@ -129,3 +133,3 @@ if (allowQueryUnsorted) records = _sortBy(records, 'id') | ||
test('deleteByQuery even=false', async () => { | ||
const q = new DBQuery<TestItemDBM>(TEST_TABLE).filter('even', '=', false) | ||
const q = new DBQuery<TestItemBM, TestItemDBM>(TEST_TABLE).filter('even', '=', false) | ||
const deleted = await db.deleteByQuery(q) | ||
@@ -132,0 +136,0 @@ expect(deleted).toBe(items.filter(item => !item.even).length) |
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
Sorry, the diff of this file is not supported yet
199103
3775