techfort / LokiJS

javascript embeddable / in-memory database
http:/techfort.github.io/LokiJS
MIT License
6.71k stars 478 forks source link

Fix disableFreeze flag #918

Open VasilisTert opened 1 year ago

VasilisTert commented 1 year ago

The flag disableFreeze is in collection not in this. Now it returns undefined so the object is always cloned.

AntonNevsgodov commented 1 year ago

Until this PR is merged (never, I guess), this monkeypatch can be a viable solution:

// TypeScript
import LokiJS from 'lokijs';

// Make Resultset.disableFreeze a property with getter that returns Collection.disableFreeze property value.
Object.defineProperty((LokiJS as any).Resultset.prototype, 'disableFreeze', {
  get() {
    return this.collection.disableFreeze;
  },
});