@dnax/core 0.64.6 → 0.64.8
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/driver/mongo/rest.ts +16 -5
- package/driver/mongo/utils.ts +2 -0
- package/package.json +1 -1
package/driver/mongo/rest.ts
CHANGED
|
@@ -2023,19 +2023,30 @@ class useRest {
|
|
|
2023
2023
|
}
|
|
2024
2024
|
}
|
|
2025
2025
|
|
|
2026
|
-
abortTransaction() {
|
|
2026
|
+
async abortTransaction() {
|
|
2027
2027
|
if (this.#session) {
|
|
2028
|
-
this.#session?.abortTransaction();
|
|
2028
|
+
await this.#session?.abortTransaction();
|
|
2029
2029
|
}
|
|
2030
2030
|
}
|
|
2031
|
-
|
|
2031
|
+
|
|
2032
|
+
async endSession() {
|
|
2033
|
+
if (this.#session) {
|
|
2034
|
+
await this.#session?.endSession();
|
|
2035
|
+
this.#session = null;
|
|
2036
|
+
}
|
|
2037
|
+
}
|
|
2038
|
+
|
|
2039
|
+
async commitTransaction(options?: { closeSession?: boolean }) {
|
|
2032
2040
|
return new Promise(async (resolve, reject) => {
|
|
2033
2041
|
if (this.#session) {
|
|
2034
2042
|
await this.#session
|
|
2035
2043
|
?.commitTransaction()
|
|
2036
2044
|
.then((e) => {
|
|
2037
|
-
|
|
2038
|
-
|
|
2045
|
+
let endSession = options?.closeSession ?? true;
|
|
2046
|
+
if (endSession) {
|
|
2047
|
+
this.#session?.endSession();
|
|
2048
|
+
this.#session = null;
|
|
2049
|
+
}
|
|
2039
2050
|
resolve(true);
|
|
2040
2051
|
})
|
|
2041
2052
|
.catch((err) => {
|
package/driver/mongo/utils.ts
CHANGED
|
@@ -242,6 +242,7 @@ function deepSetId(col: Collection, data: any) {
|
|
|
242
242
|
if (col) {
|
|
243
243
|
col?.fields?.map((f) => {
|
|
244
244
|
if (f?.type?.match(/(json|array)/) && data[f?.name]) {
|
|
245
|
+
|
|
245
246
|
if (f?.injectAutoId && f?.type == "array") {
|
|
246
247
|
data[f.name]?.map((d, index) => {
|
|
247
248
|
if (!d?._id) {
|
|
@@ -256,6 +257,7 @@ function deepSetId(col: Collection, data: any) {
|
|
|
256
257
|
}
|
|
257
258
|
}
|
|
258
259
|
}
|
|
260
|
+
|
|
259
261
|
|
|
260
262
|
if (f?.type?.match(/(relationship|media)/) && data[f.name]) {
|
|
261
263
|
if (typeof data[f.name] == "object" && !Array.isArray(data[f.name])) {
|