Skip to content

v0.12.0

Compare
Choose a tag to compare
@maradotwebp maradotwebp released this 01 May 22:01
· 158 commits to main since this release
a7569d8

BREAKING CHANGES

  • watch() now returns the method to stop watching changes directly instead of an object with the stop method.

Before:

const { stop } = await watch(...);

After:

const stop = await watch(...);
  • All exceptions have been rewritten to custom classes that extend Error, so checking for problems is easier.

Before:

import { insert } from "blinkdb";

try {
  await insert(userTable, ...);
} catch(e) {
  // Check if the error is due to the primary key already existing.
  if(e.message.match(/Primary key .* already in use./g)) {
    console.log("Key in use :(");
  }
}

After:

import { insert, PrimaryKeyAlreadyInUseError } from "blinkdb";

try {
  await insert(userTable, ...);
} catch(e) {
  // Check if the error is due to the primary key already existing.
  if(e instanceof PrimaryKeyAlreadyInUseError) {
    console.log("Key in use :(");
  }
}

What's changed

  • update() & updateMany() now return the primary keys of the items updated.
  • New upsert(...) & upsertMany(...) that update an entity, or insert it if it's not yet present within the table.
  • first() & one() now also accept an id directly as the second parameter, which is a faster method than using a query { where: { id: "<id>" } }.
  • watch() has been rewritten with increased performance and correctness.
    • fixed issue with watch() returning incorrect data if a limit is specified.
    • used better algorithm for inserting newer entities into the sorted list instead of inserting & sorting afterwards.

Full Changelog: https://github.com/blinkdb-js/blinkdb/commits/v0.12.0