alexberriman / newtondb

A simple, easy to use and extendible JSON database.
https://github.com/alexberriman/newtondb
MIT License
17 stars 1 forks source link

Can not mutate/add values to an array #29

Closed alexberriman closed 1 year ago

alexberriman commented 1 year ago

Description

When trying to add values to an array the value isn't mutated.

e.g. you would expect this test to pass:

it("updates an empty array", () => {
  const $ = new Collection<{
    color: string;
    contents: string[];
    animal: string;
  }>(
    [
      { color: "green", contents: ["apple"], animal: "gorilla" },
      { color: "red", contents: [], animal: "monkey" },
    ],
    { primaryKey: "color" }
  );

  $.get({ color: "red" })
    .set({ contents: ["orange", "banana"], animal: "giraffe" })
    .commit();

  expect($.get({ color: "red" }).data).toEqual({
    animal: "giraffe",
    color: "red",
    contents: ["orange", "banana"],
  });
});

However after mutation the value of contents is still an empty array.

alexberriman commented 1 year ago

:tada: This issue has been resolved in version 0.3.3 :tada:

The release is available on:

Your semantic-release bot :package::rocket: