fix: slow types

This commit is contained in:
2025-08-14 23:57:47 +02:00
parent fab3476515
commit ca6a692631
3 changed files with 12 additions and 6 deletions

View File

@@ -1,6 +1,6 @@
import { UpdateOptions } from "mingo/core"; import { UpdateOptions } from "mingo/core";
import { UpdateExpression } from "mingo/updater"; import { UpdateExpression } from "mingo/updater";
import { Observable, Subscription } from "rxjs"; import { Observable, Subject, Subscription } from "rxjs";
import { observe, observeOne } from "./observe/mod.ts"; import { observe, observeOne } from "./observe/mod.ts";
import { import {
@@ -26,7 +26,10 @@ export class Collection<TSchema extends Document = Document> {
readonly storage: Storage<TSchema>, readonly storage: Storage<TSchema>,
) {} ) {}
get observable() { get observable(): {
change: Subject<ChangeEvent<TSchema>>;
flush: Subject<void>;
} {
return this.storage.observable; return this.storage.observable;
} }

View File

@@ -1,5 +1,5 @@
class Performance { class Performance {
startedAt = performance.now(); startedAt: number = performance.now();
endedAt?: number; endedAt?: number;
duration?: number; duration?: number;
@@ -10,7 +10,7 @@ class Performance {
} }
abstract class LogEvent { abstract class LogEvent {
readonly performance = new Performance(); readonly performance: Performance = new Performance();
data?: Record<string, any>; data?: Record<string, any>;

View File

@@ -10,7 +10,10 @@ import { RemoveResult } from "./operators/remove.ts";
import { UpdateResult } from "./operators/update.ts"; import { UpdateResult } from "./operators/update.ts";
export abstract class Storage<TSchema extends Document = Document> { export abstract class Storage<TSchema extends Document = Document> {
readonly observable = { readonly observable: {
change: Subject<ChangeEvent<TSchema>>;
flush: Subject<void>;
} = {
change: new Subject<ChangeEvent<TSchema>>(), change: new Subject<ChangeEvent<TSchema>>(),
flush: new Subject<void>(), flush: new Subject<void>(),
}; };
@@ -21,7 +24,7 @@ export abstract class Storage<TSchema extends Document = Document> {
constructor( constructor(
readonly name: string, readonly name: string,
readonly id = crypto.randomUUID(), readonly id: string = crypto.randomUUID(),
) { ) {
this.#channel = new BroadcastChannel(`valkyr:db:${name}`); this.#channel = new BroadcastChannel(`valkyr:db:${name}`);
this.#channel.onmessage = ({ data }: MessageEvent<StorageBroadcast<TSchema>>) => { this.#channel.onmessage = ({ data }: MessageEvent<StorageBroadcast<TSchema>>) => {