speedly 1.2.48 → 1.3.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/dist/cjs/db/db.d.ts +1 -0
- package/dist/cjs/db/db.js +10 -2
- package/dist/esm/db/db.d.ts +1 -0
- package/dist/esm/db/db.js +10 -2
- package/package.json +1 -1
package/dist/cjs/db/db.d.ts
CHANGED
package/dist/cjs/db/db.js
CHANGED
|
@@ -14,6 +14,7 @@ let configs = {
|
|
|
14
14
|
path: "../models",
|
|
15
15
|
type: "external",
|
|
16
16
|
dbEnv: "DB_URL",
|
|
17
|
+
first: false,
|
|
17
18
|
response: true,
|
|
18
19
|
...(0, getConfig_1.default)("db"),
|
|
19
20
|
};
|
|
@@ -488,6 +489,8 @@ const usingMongoDb = (collectionName, config = { type: "external" }) => {
|
|
|
488
489
|
}
|
|
489
490
|
if (config?.response) {
|
|
490
491
|
const action = queryState.action?.match(/create|update|delet/i)?.[0] || "find";
|
|
492
|
+
if (queryState.action == "aggregate" && config.first && data[0]?.content.length)
|
|
493
|
+
data[0].content.length = data[0].content[0];
|
|
491
494
|
const resBody = queryState.action == "aggregate"
|
|
492
495
|
? {
|
|
493
496
|
message: config?.message ||
|
|
@@ -497,11 +500,15 @@ const usingMongoDb = (collectionName, config = { type: "external" }) => {
|
|
|
497
500
|
}
|
|
498
501
|
: {
|
|
499
502
|
content: data,
|
|
500
|
-
...{
|
|
503
|
+
...{
|
|
504
|
+
detail: Object.keys(detail).length ? detail : undefined,
|
|
505
|
+
},
|
|
501
506
|
message: config?.message ||
|
|
502
507
|
`the ${collectionName} was ${action == "find" ? "found" : action + "ed"}`,
|
|
503
508
|
};
|
|
504
|
-
res.success
|
|
509
|
+
res.success
|
|
510
|
+
? res.success(200, resBody)
|
|
511
|
+
: res.status(200).json(resBody);
|
|
505
512
|
}
|
|
506
513
|
else {
|
|
507
514
|
next();
|
|
@@ -585,6 +592,7 @@ const db = (collectionName, config = configs) => {
|
|
|
585
592
|
path: "../models",
|
|
586
593
|
dbEnv: "DB_URL",
|
|
587
594
|
type: "external",
|
|
595
|
+
first: false,
|
|
588
596
|
response: true,
|
|
589
597
|
...(0, getConfig_1.default)("db"),
|
|
590
598
|
};
|
package/dist/esm/db/db.d.ts
CHANGED
package/dist/esm/db/db.js
CHANGED
|
@@ -14,6 +14,7 @@ let configs = {
|
|
|
14
14
|
path: "../models",
|
|
15
15
|
type: "external",
|
|
16
16
|
dbEnv: "DB_URL",
|
|
17
|
+
first: false,
|
|
17
18
|
response: true,
|
|
18
19
|
...(0, getConfig_1.default)("db"),
|
|
19
20
|
};
|
|
@@ -488,6 +489,8 @@ const usingMongoDb = (collectionName, config = { type: "external" }) => {
|
|
|
488
489
|
}
|
|
489
490
|
if (config?.response) {
|
|
490
491
|
const action = queryState.action?.match(/create|update|delet/i)?.[0] || "find";
|
|
492
|
+
if (queryState.action == "aggregate" && config.first && data[0]?.content.length)
|
|
493
|
+
data[0].content.length = data[0].content[0];
|
|
491
494
|
const resBody = queryState.action == "aggregate"
|
|
492
495
|
? {
|
|
493
496
|
message: config?.message ||
|
|
@@ -497,11 +500,15 @@ const usingMongoDb = (collectionName, config = { type: "external" }) => {
|
|
|
497
500
|
}
|
|
498
501
|
: {
|
|
499
502
|
content: data,
|
|
500
|
-
...{
|
|
503
|
+
...{
|
|
504
|
+
detail: Object.keys(detail).length ? detail : undefined,
|
|
505
|
+
},
|
|
501
506
|
message: config?.message ||
|
|
502
507
|
`the ${collectionName} was ${action == "find" ? "found" : action + "ed"}`,
|
|
503
508
|
};
|
|
504
|
-
res.success
|
|
509
|
+
res.success
|
|
510
|
+
? res.success(200, resBody)
|
|
511
|
+
: res.status(200).json(resBody);
|
|
505
512
|
}
|
|
506
513
|
else {
|
|
507
514
|
next();
|
|
@@ -585,6 +592,7 @@ const db = (collectionName, config = configs) => {
|
|
|
585
592
|
path: "../models",
|
|
586
593
|
dbEnv: "DB_URL",
|
|
587
594
|
type: "external",
|
|
595
|
+
first: false,
|
|
588
596
|
response: true,
|
|
589
597
|
...(0, getConfig_1.default)("db"),
|
|
590
598
|
};
|