mirror of
https://github.com/appy-one/acebase.git
synced 2026-06-30 06:02:02 -06:00
Merge branch 'master' into improvement/typescript-port
This commit is contained in:
commit
3c72ee8e59
12 changed files with 65 additions and 11 deletions
2
package-lock.json
generated
2
package-lock.json
generated
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "acebase",
|
||||
"version": "1.24.4",
|
||||
"version": "1.24.5",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "acebase",
|
||||
"version": "1.24.4",
|
||||
"version": "1.24.5",
|
||||
"description": "AceBase realtime database. Open source firebase alternative for nodejs and browser, with additional features: indexes, geo, fulltext, queries, custom storage, offline usage, synchronization, live data proxies and more",
|
||||
"main": "./src/index.js",
|
||||
"browser": {
|
||||
|
|
|
|||
|
|
@ -683,3 +683,51 @@ describe('Query on indexed BigInts #141', () => {
|
|||
expect(snaps.length).toEqual(8);
|
||||
}, 60e3);
|
||||
});
|
||||
|
||||
describe('Query on indexed BigInts #152', () => {
|
||||
// Created for https://github.com/appy-one/acebase/issues/152, with adjustments of https://github.com/appy-one/acebase/pull/159/files
|
||||
|
||||
/** @type {AceBase} */
|
||||
let db;
|
||||
/** @type {{(): Promise<void>}} */
|
||||
let removeDB;
|
||||
|
||||
/** @type {DataReference} */
|
||||
let moviesRef;
|
||||
|
||||
beforeAll(async () => {
|
||||
({ db, removeDB } = await createTempDB());
|
||||
moviesRef = db.ref('movies');
|
||||
|
||||
const movies = require('./dataset/movies.json').map(movie => {
|
||||
return {
|
||||
title: movie.title,
|
||||
rating: movie.rating,
|
||||
year: movie.year,
|
||||
votes: BigInt(movie.votes),
|
||||
};
|
||||
});
|
||||
await db.indexes.create('movies', 'title');
|
||||
await db.indexes.create('movies', 'rating');
|
||||
await db.indexes.create('movies', 'votes');
|
||||
|
||||
for (const movie of movies) {
|
||||
await moviesRef.push(movie);
|
||||
}
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
await removeDB();
|
||||
});
|
||||
|
||||
it('filter on BigInt', async () => {
|
||||
let query = moviesRef.query().filter('votes', '>', BigInt(1_500_000));
|
||||
let snaps = await query.get();
|
||||
expect(snaps.length).toEqual(5);
|
||||
|
||||
// Try again, now with cached results
|
||||
snaps = await query.get();
|
||||
expect(snaps.length).toEqual(5);
|
||||
}, 60e3);
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ class BinaryWriter {
|
|||
},
|
||||
end(callback) {
|
||||
callback();
|
||||
return this;
|
||||
},
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
once(event, callback) {
|
||||
|
|
@ -58,6 +59,7 @@ class BinaryWriter {
|
|||
},
|
||||
end(callback) {
|
||||
callback();
|
||||
return this;
|
||||
},
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
once(event, callback) {
|
||||
|
|
@ -120,6 +122,7 @@ class BinaryWriter {
|
|||
if (pendingWrites === 0) {
|
||||
callback();
|
||||
}
|
||||
return this;
|
||||
},
|
||||
once(event, callback) {
|
||||
console.assert(event === 'drain', 'Custom stream can only handle "drain" event');
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -418,7 +418,7 @@ class DataIndex {
|
|||
// return this._updateTree(path, revLookupKey, revLookupKey, oldData, newData, metadata);
|
||||
// }
|
||||
_updateTree(path, oldValue, newValue, oldRecordPointer, newRecordPointer, metadata) {
|
||||
const canBeIndexed = ['number', 'boolean', 'string'].indexOf(typeof newValue) >= 0 || newValue instanceof Date;
|
||||
const canBeIndexed = ['number', 'boolean', 'string', 'bigint'].indexOf(typeof newValue) >= 0 || newValue instanceof Date;
|
||||
const operations = [];
|
||||
if (oldValue !== null) {
|
||||
const op = btree_1.BinaryBPlusTree.TransactionOperation.remove(oldValue, oldRecordPointer);
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
4
src/promise-fs/index.d.ts
vendored
4
src/promise-fs/index.d.ts
vendored
|
|
@ -76,7 +76,7 @@ export declare abstract class pfs {
|
|||
* @param options.flag see pfs.flags, default is pfs.flags.write ('w')
|
||||
* @returns {} returns a promise that resolves once the file has been written
|
||||
*/
|
||||
static writeFile(path: string | Buffer | number | fs.PathLike, data: string | Buffer | TypedArray | DataView, options?: string | {
|
||||
static writeFile(path: string | Buffer | number | fs.PathLike, data: string | Buffer | TypedArray | DataView, options?: BufferEncoding | {
|
||||
encoding?: BufferEncoding;
|
||||
mode?: number;
|
||||
flag?: string;
|
||||
|
|
@ -102,7 +102,7 @@ export declare abstract class pfs {
|
|||
* @param options.flag see pfs.flags, default is pfs.flags.read ('r')
|
||||
* @returns returns a promise that resolves with a string if an encoding was specified, or a raw buffer otherwise
|
||||
*/
|
||||
static readFile(path: string | Buffer | number | fs.PathLike, options: string | {
|
||||
static readFile(path: string | Buffer | number | fs.PathLike, options: BufferEncoding | {
|
||||
encoding: BufferEncoding | null;
|
||||
flag: string;
|
||||
}): Promise<Buffer | string>;
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -35,6 +35,7 @@ export class BinaryWriter {
|
|||
},
|
||||
end(callback: () => unknown) {
|
||||
callback();
|
||||
return this;
|
||||
},
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
once(event: string, callback: (...args: any[]) => void) {
|
||||
|
|
@ -66,6 +67,7 @@ export class BinaryWriter {
|
|||
},
|
||||
end(callback: () => unknown) {
|
||||
callback();
|
||||
return this;
|
||||
},
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
once(event: string, callback: (...args: any[]) => void) {
|
||||
|
|
@ -128,6 +130,7 @@ export class BinaryWriter {
|
|||
if (pendingWrites === 0) {
|
||||
callback();
|
||||
}
|
||||
return this;
|
||||
},
|
||||
once(event: string, callback: (...args: any[]) => void) {
|
||||
console.assert(event === 'drain', 'Custom stream can only handle "drain" event');
|
||||
|
|
|
|||
|
|
@ -514,7 +514,7 @@ export class DataIndex {
|
|||
// }
|
||||
|
||||
_updateTree(path: string, oldValue: IndexableValue, newValue: IndexableValue, oldRecordPointer: IndexRecordPointer, newRecordPointer: IndexRecordPointer, metadata: IndexMetaData) {
|
||||
const canBeIndexed = ['number','boolean','string'].indexOf(typeof newValue) >= 0 || newValue instanceof Date;
|
||||
const canBeIndexed = ['number','boolean','string','bigint'].indexOf(typeof newValue) >= 0 || newValue instanceof Date;
|
||||
const operations = [];
|
||||
if (oldValue !== null) {
|
||||
const op = BinaryBPlusTree.TransactionOperation.remove(oldValue, oldRecordPointer);
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ export abstract class pfs {
|
|||
* @param options.flag see pfs.flags, default is pfs.flags.write ('w')
|
||||
* @returns {} returns a promise that resolves once the file has been written
|
||||
*/
|
||||
static writeFile(path:string|Buffer|number|fs.PathLike, data: string|Buffer|TypedArray|DataView, options?:string|{ encoding?: BufferEncoding, mode?: number, flag?: string }): Promise<void> {
|
||||
static writeFile(path:string|Buffer|number|fs.PathLike, data: string|Buffer|TypedArray|DataView, options?:BufferEncoding | { encoding?: BufferEncoding, mode?: number, flag?: string }): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
fs.writeFile(path, data, options, err => {
|
||||
if (err) { reject(err); }
|
||||
|
|
@ -159,7 +159,7 @@ export abstract class pfs {
|
|||
* @param options.flag see pfs.flags, default is pfs.flags.read ('r')
|
||||
* @returns returns a promise that resolves with a string if an encoding was specified, or a raw buffer otherwise
|
||||
*/
|
||||
static readFile(path: string|Buffer|number|fs.PathLike, options:string|{ encoding: BufferEncoding|null, flag: string }): Promise<Buffer|string> {
|
||||
static readFile(path: string|Buffer|number|fs.PathLike, options:BufferEncoding |{ encoding: BufferEncoding|null, flag: string }): Promise<Buffer|string> {
|
||||
return new Promise((resolve, reject) => {
|
||||
fs.readFile(path, options, (err, data) => {
|
||||
if (err) { reject(err); }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue