Skip to content

Releases: alfateam/orange-orm

v4.4.1

19 Nov 07:23
Compare
Choose a tag to compare

Support for date-only ISO strings. #116

v4.3.0

07 Jul 19:31
Compare
Choose a tag to compare

Minor performance improvements

v4.2.0

25 Jun 13:48
Compare
Choose a tag to compare

Improved performance
See benchmarks here https://github.com/alfateam/orm-benchmarks

v4.1.2

10 Jun 20:24
639e516
Compare
Choose a tag to compare

Bugfix with composite primary key with hasMany relation. #106

v4.1.0

07 Jun 08:57
Compare
Choose a tag to compare

Escape table and column names. #91 #92
NotNullable relations #104

v4.0.1

06 Jun 10:40
Compare
Choose a tag to compare

Using inhouse definitions of ajv to avoid trouble with nestjs.

v4.0.0

28 May 20:22
Compare
Choose a tag to compare

Changed the behaviour of update to accept a where filter and only update passed in columns and relations. The previous behaviour of update has moved to replace method.

From the docs:

__Selective updates__  
The update method is ideal for updating specific columns and relationships across one or multiple rows. You must provide a where filter to specify which rows to target. If you include a fetching strategy, the affected rows and their related data will be returned; otherwise, no data is returned.

```javascript
import map from './map';
const db = map.sqlite('demo.db');

update();

async function update() {

  const propsToBeModified = {
    orderDate: new Date(),
    customerId: 2,
    lines: [
      { id: 1, product: 'Bicycle', amount: 250 }, //already existing line
      { id: 2, product: 'Small guitar', amount: 150 }, //already existing line
      { product: 'Piano', amount: 800 } //the new line to be inserted
    ]
  };

  const strategy = {customer: true, deliveryAddress: true, lines: true};
  const orders = await db.order.update(propsToBeModified, { where: x => x.id.eq(1) }, strategy);
}

Replacing a row from JSON
The replace method is suitable when a complete overwrite is required from a JSON object - typically in a REST API. However, it's important to consider that this method replaces the entire row and it's children, which might not always be desirable in a multi-user environment.

import map from './map';
const db = map.sqlite('demo.db');

replace();

async function replace() {

  const modified = {
    id: 1,
    orderDate: '2023-07-14T12:00:00',
    customer: {
      id: 2
    },
    deliveryAddress: {
      name: 'Roger', //modified name
      street: 'Node street 1',
      postalCode: '7059',
      postalPlace: 'Jakobsli',
      countryCode: 'NO'
    },
    lines: [
      { id: 1, product: 'Bicycle', amount: 250 },
      { id: 2, product: 'Small guitar', amount: 150 },
      { product: 'Piano', amount: 800 } //the new line to be inserted
    ]
  };

  const order = await db.order.replace(modified, {customer: true, deliveryAddress: true, lines: true});
}

v3.10.3

23 May 14:45
Compare
Choose a tag to compare

Fix duplicate signature for those still using code generation

v3.10.2

18 May 07:31
Compare
Choose a tag to compare

RDB was renamed to orange-orm
Install from npmjs.org/package/orange-orm

v3.10.1

15 May 13:00
Compare
Choose a tag to compare

Bugfix: Adding hasOne row to existing parent throws. See #86