orbitjs / orbit

Composable data framework for ambitious web applications.
https://orbitjs.com
MIT License
2.33k stars 134 forks source link

Documentation incorrect on adding records #886

Closed bradjones1 closed 2 years ago

bradjones1 commented 3 years ago

When following the documentation at https://orbitjs.com/docs/next/updating-data#transforms for adding a record, if you use the snippet as-is, with the arrow function returning t.addRecord() directly, Orbit 0.17 beta fails with

Unhandled Rejection (TypeError): transform is undefined in isTransform at /src/transform.ts:113

I noticed the snippet just below, where you can return an array of transforms, and tried that instead (basically, an array of one.) This works.

is this a BC break in 0.17 from a previous behavior, or are the docs wrong?

dgeb commented 3 years ago

@bradjones1 can you provide a reproduction, perhaps based on this codesandbox ?

Both of the following forms (single operation / array of operations) appear to be working with v0.17-beta.25:

  await memory.update((t) => t.addRecord(jupiter));

  await memory.update((t) => [
    t.addRecord(earth),
    t.addRecord(venus),
    t.addRecord(io),
    t.addRecord(europa),
    t.addRecord(theMoon)
  ]);
bradjones1 commented 2 years ago

I can no longer recreate this.