feat: release 3.0.0
This commit is contained in:
@@ -7,6 +7,18 @@ export class PrimaryIndex<TSchema extends AnyDocument> {
|
||||
|
||||
constructor(readonly key: string) {}
|
||||
|
||||
get documents() {
|
||||
return Array.from(this.#index.values());
|
||||
}
|
||||
|
||||
keys() {
|
||||
return Array.from(this.#index.keys());
|
||||
}
|
||||
|
||||
has(pk: PrimaryKey): boolean {
|
||||
return this.#index.has(pk);
|
||||
}
|
||||
|
||||
insert(pk: PrimaryKey, document: TSchema) {
|
||||
if (this.#index.has(pk)) {
|
||||
throw new Error(`Duplicate primary key: ${pk}`);
|
||||
@@ -18,7 +30,15 @@ export class PrimaryIndex<TSchema extends AnyDocument> {
|
||||
return this.#index.get(pk);
|
||||
}
|
||||
|
||||
replace(pk: PrimaryKey, document: TSchema) {
|
||||
this.#index.set(pk, document);
|
||||
}
|
||||
|
||||
delete(pk: PrimaryKey) {
|
||||
this.#index.delete(pk);
|
||||
}
|
||||
|
||||
flush() {
|
||||
this.#index.clear();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user