orange-orm 4.1.3 → 4.2.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
  <img src="./docs/orange.svg" alt="Orange ORM Logo" width="250"/>
3
3
  </div>
4
4
 
5
- The ultimate Object Relational Mapper for Node.js and Typescript, offering seamless integration with a variety of popular databases. Whether you're building applications in TypeScript or JavaScript (including both CommonJS and ECMAScript), Orange ORM has got you covered.
5
+ The ultimate Object Relational Mapper for Node.js and Typescript, offering seamless integration with a variety of popular databases. Whether you're building applications in TypeScript or JavaScript, including both CommonJS and ECMAScript, Orange ORM has got you covered.
6
6
 
7
7
  [![npm version](https://img.shields.io/npm/v/orange-orm.svg?style=flat-square)](https://www.npmjs.org/package/orange-orm)
8
8
  [![Build status](https://github.com/alfateam/orange-orm/workflows/Node.js%20CI/badge.svg)](https://github.com/alfateam/orange-orm/actions)
@@ -20,7 +20,7 @@ The ultimate Object Relational Mapper for Node.js and Typescript, offering seaml
20
20
  - **Active Record**: With a concise and expressive syntax, Orange enables you to interact with your database using the [*Active Record Pattern*](https://en.wikipedia.org/wiki/Active_record_pattern).
21
21
  - **No Code Generation Required**: Enjoy full IntelliSense, even in table mappings, without the need for cumbersome code generation.
22
22
  - **TypeScript and JavaScript Support**: Orange fully supports both TypeScript and JavaScript, allowing you to leverage the benefits of static typing and modern ECMAScript features.
23
- - **Works in the Browser**: You can securely use Orange in the browser by utilizing the Express.js plugin, which serves to safeguard sensitive database credentials from exposure at the client level. This method mirrors a traditional REST API, augmented with advanced TypeScript tooling for enhanced functionality.
23
+ - **Works in the Browser**: You can securely use Orange in the browser by utilizing the Express.js plugin, which serves to safeguard sensitive database credentials from exposure at the client level and protect against SQL injection. This method mirrors a traditional REST API, augmented with advanced TypeScript tooling for enhanced functionality.
24
24
 
25
25
  ## Supported Databases
26
26
 
@@ -139,7 +139,7 @@ getRows();
139
139
  async function getRows() {
140
140
  const orders = await db.order.getAll({
141
141
  where: x => x.lines.any(line => line.product.contains('broomstick'))
142
- .and(db.order.customer.name.startsWith('Harry')),
142
+ .and(x.customer.name.startsWith('Harry')),
143
143
  lines: {
144
144
  packages: true
145
145
  },
@@ -831,7 +831,7 @@ async function update() {
831
831
  };
832
832
 
833
833
  const modified = JSON.parse(JSON.stringify(original));
834
- deliveryAddress.name = 'Roger';
834
+ modified.deliveryAddress.name = 'Roger';
835
835
  modified.lines.push({ product: 'Piano', amount: 800 });
836
836
 
837
837
  const order = await db.order.updateChanges(modified, original, { customer: true, deliveryAddress: true, lines: true });
package/docs/changelog.md CHANGED
@@ -1,4 +1,6 @@
1
1
  ## Changelog
2
+ __4.1.4__
3
+ Better error message when running over http.
2
4
  __4.1.3__
3
5
  Do not use transaction in readonly operations. [#109](https://github.com/alfateam/orange-orm/issues/109)
4
6
  __4.1.2__
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orange-orm",
3
- "version": "4.1.3",
3
+ "version": "4.2.0-beta.0",
4
4
  "main": "./src/index.js",
5
5
  "browser": "./src/client/index.mjs",
6
6
  "bin": {
@@ -4842,8 +4842,8 @@ function httpAdapter(baseURL, path, axiosInterceptor) {
4842
4842
  return res.data;
4843
4843
  }
4844
4844
  catch (e) {
4845
- if (e.response?.data)
4846
- throw new Error(e.response?.data.replace(/^Error: /, ''));
4845
+ if (typeof e.response?.data === 'string')
4846
+ throw new Error(e.response.data.replace(/^Error: /, ''));
4847
4847
  else
4848
4848
  throw e;
4849
4849
  }
@@ -4857,9 +4857,9 @@ function httpAdapter(baseURL, path, axiosInterceptor) {
4857
4857
  const res = await axios.request(path, { headers, method: 'patch', data: body });
4858
4858
  return res.data;
4859
4859
  }
4860
- catch (e) {
4861
- if (e.response?.data)
4862
- throw new Error(e.response?.data.replace(/^Error: /, ''));
4860
+ catch (e) {
4861
+ if (typeof e.response?.data === 'string')
4862
+ throw new Error(e.response.data.replace(/^Error: /, ''));
4863
4863
  else
4864
4864
  throw e;
4865
4865
  }
@@ -4874,8 +4874,8 @@ function httpAdapter(baseURL, path, axiosInterceptor) {
4874
4874
  return res.data;
4875
4875
  }
4876
4876
  catch (e) {
4877
- if (e.response?.data)
4878
- throw new Error(e.response?.data.replace(/^Error: /, ''));
4877
+ if (typeof e.response?.data === 'string')
4878
+ throw new Error(e.response.data.replace(/^Error: /, ''));
4879
4879
  else throw e;
4880
4880
  }
4881
4881
  }
@@ -22,8 +22,8 @@ function httpAdapter(baseURL, path, axiosInterceptor) {
22
22
  return res.data;
23
23
  }
24
24
  catch (e) {
25
- if (e.response?.data)
26
- throw new Error(e.response?.data.replace(/^Error: /, ''));
25
+ if (typeof e.response?.data === 'string')
26
+ throw new Error(e.response.data.replace(/^Error: /, ''));
27
27
  else
28
28
  throw e;
29
29
  }
@@ -38,8 +38,8 @@ function httpAdapter(baseURL, path, axiosInterceptor) {
38
38
  return res.data;
39
39
  }
40
40
  catch (e) {
41
- if (e.response?.data)
42
- throw new Error(e.response?.data.replace(/^Error: /, ''));
41
+ if (typeof e.response?.data === 'string')
42
+ throw new Error(e.response.data.replace(/^Error: /, ''));
43
43
  else
44
44
  throw e;
45
45
  }
@@ -54,8 +54,8 @@ function httpAdapter(baseURL, path, axiosInterceptor) {
54
54
  return res.data;
55
55
  }
56
56
  catch (e) {
57
- if (e.response?.data)
58
- throw new Error(e.response?.data.replace(/^Error: /, ''));
57
+ if (typeof e.response?.data === 'string')
58
+ throw new Error(e.response.data.replace(/^Error: /, ''));
59
59
  else throw e;
60
60
  }
61
61
  }