leoric 2.3.1 → 2.3.2
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/History.md +14 -0
- package/Readme.md +28 -2
- package/package.json +1 -1
- package/src/adapters/sequelize.js +2 -0
- package/src/bone.js +3 -2
- package/src/realm.js +1 -1
package/History.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
2.3.2 / 2022-04-15
|
|
2
|
+
==================
|
|
3
|
+
|
|
4
|
+
## What's Changed
|
|
5
|
+
* fix: order by raw with mix-type array in sequelize mode by @JimmyDaddy in https://github.com/cyjake/leoric/pull/298
|
|
6
|
+
* docs: monthly updates and example about egg-orm usage with TypeScript by @cyjake in https://github.com/cyjake/leoric/pull/299
|
|
7
|
+
* docs: monthly updates in en & docmentation about typescript support by @cyjake in https://github.com/cyjake/leoric/pull/300
|
|
8
|
+
* fix: raw query should format replacements with extra blank by @JimmyDaddy in https://github.com/cyjake/leoric/pull/301
|
|
9
|
+
* docs: elaborate on querying by @cyjake in https://github.com/cyjake/leoric/pull/302
|
|
10
|
+
* feat: transaction should return result by @JimmyDaddy in https://github.com/cyjake/leoric/pull/303
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
**Full Changelog**: https://github.com/cyjake/leoric/compare/v2.3.1...v2.3.2
|
|
14
|
+
|
|
1
15
|
2.3.1 / 2022-03-22
|
|
2
16
|
==================
|
|
3
17
|
|
package/Readme.md
CHANGED
|
@@ -74,6 +74,32 @@ await realm.sync();
|
|
|
74
74
|
|
|
75
75
|
A more detailed syntax table may be found at the [documentation](https://leoric.js.org/#syntax-table) site.
|
|
76
76
|
|
|
77
|
+
## TypeScript charged
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
import { Bone, BelongsTo, Column, DataTypes: { TEXT } } from 'leoric';
|
|
81
|
+
import User from './user';
|
|
82
|
+
|
|
83
|
+
export default class Post extends Bone {
|
|
84
|
+
@Column({ autoIncrement: true })
|
|
85
|
+
id: bigint;
|
|
86
|
+
|
|
87
|
+
@Column(TEXT)
|
|
88
|
+
content: string;
|
|
89
|
+
|
|
90
|
+
@Column()
|
|
91
|
+
description: string;
|
|
92
|
+
|
|
93
|
+
@Column()
|
|
94
|
+
userId: bigint;
|
|
95
|
+
|
|
96
|
+
@BelongsTo()
|
|
97
|
+
user: User;
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
More about TypeScript integration examples can be found at [the TypeScript support documentation](https://leoric.js.org/types)
|
|
102
|
+
|
|
77
103
|
## Contributing
|
|
78
104
|
|
|
79
105
|
There are many ways in which you can participate in the project, for example:
|
|
@@ -89,6 +115,6 @@ If you are interested in fixing issues and contributing directly to the code bas
|
|
|
89
115
|
- Submitting pull requests
|
|
90
116
|
- Contributing to translations
|
|
91
117
|
|
|
92
|
-
##
|
|
118
|
+
## egg-orm
|
|
93
119
|
|
|
94
|
-
If developing web applications with [egg framework](https://eggjs.org/), it's highly recommended using the [egg-orm](https://github.com/eggjs/egg-orm) plugin.
|
|
120
|
+
If developing web applications with [egg framework](https://eggjs.org/), it's highly recommended using the [egg-orm](https://github.com/eggjs/egg-orm) plugin. More detailed examples about setting up egg-orm with egg framework in either JavaScript or TypeScript can be found at <https://github.com/eggjs/egg-orm/tree/master/examples>
|
package/package.json
CHANGED
package/src/bone.js
CHANGED
|
@@ -1567,11 +1567,12 @@ class Bone {
|
|
|
1567
1567
|
|
|
1568
1568
|
static async transaction(callback) {
|
|
1569
1569
|
const connection = await this.driver.getConnection();
|
|
1570
|
+
let result;
|
|
1570
1571
|
if (callback.constructor.name === 'AsyncFunction') {
|
|
1571
1572
|
// if callback is an AsyncFunction
|
|
1572
1573
|
await this.driver.query('BEGIN', [], { connection, Model: this, command: 'BEGIN' });
|
|
1573
1574
|
try {
|
|
1574
|
-
await callback({ connection });
|
|
1575
|
+
result = await callback({ connection });
|
|
1575
1576
|
await this.driver.query('COMMIT', [], { connection, Model: this, command: 'COMMIT' });
|
|
1576
1577
|
} catch (err) {
|
|
1577
1578
|
await this.driver.query('ROLLBACK', [], { connection, Model: this, command: 'ROLLBACK' });
|
|
@@ -1581,7 +1582,6 @@ class Bone {
|
|
|
1581
1582
|
}
|
|
1582
1583
|
} else if (callback.constructor.name === 'GeneratorFunction') {
|
|
1583
1584
|
const gen = callback({ connection });
|
|
1584
|
-
let result;
|
|
1585
1585
|
|
|
1586
1586
|
try {
|
|
1587
1587
|
await this.driver.query('BEGIN', [], { connection, Model: this, command: 'BEGIN' });
|
|
@@ -1601,6 +1601,7 @@ class Bone {
|
|
|
1601
1601
|
} else {
|
|
1602
1602
|
throw new Error('unexpected transaction function, should be GeneratorFunction or AsyncFunction.');
|
|
1603
1603
|
}
|
|
1604
|
+
return result;
|
|
1604
1605
|
}
|
|
1605
1606
|
|
|
1606
1607
|
static init(attributes = {}, opts = {}, overrides = {}) {
|
package/src/realm.js
CHANGED