@strapi/database 4.3.7 → 4.4.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/lib/entity-manager.js +4 -4
- package/lib/lifecycles/index.js +1 -1
- package/lib/query/helpers/join.js +1 -1
- package/lib/query/helpers/populate.js +5 -5
- package/lib/query/helpers/transform.js +1 -1
- package/lib/query/helpers/where.js +2 -2
- package/lib/query/query-builder.js +7 -1
- package/lib/schema/builder.js +1 -1
- package/lib/schema/schema.js +1 -1
- package/package.json +3 -3
package/lib/entity-manager.js
CHANGED
|
@@ -34,7 +34,7 @@ const processData = (metadata, data = {}, { withDefaults = false } = {}) => {
|
|
|
34
34
|
|
|
35
35
|
const obj = {};
|
|
36
36
|
|
|
37
|
-
for (const attributeName
|
|
37
|
+
for (const attributeName of Object.keys(attributes)) {
|
|
38
38
|
const attribute = attributes[attributeName];
|
|
39
39
|
|
|
40
40
|
if (types.isScalar(attribute.type)) {
|
|
@@ -333,7 +333,7 @@ const createEntityManager = (db) => {
|
|
|
333
333
|
async attachRelations(uid, id, data) {
|
|
334
334
|
const { attributes } = db.metadata.get(uid);
|
|
335
335
|
|
|
336
|
-
for (const attributeName
|
|
336
|
+
for (const attributeName of Object.keys(attributes)) {
|
|
337
337
|
const attribute = attributes[attributeName];
|
|
338
338
|
|
|
339
339
|
const isValidLink = _.has(attributeName, data) && !_.isNil(data[attributeName]);
|
|
@@ -487,7 +487,7 @@ const createEntityManager = (db) => {
|
|
|
487
487
|
async updateRelations(uid, id, data) {
|
|
488
488
|
const { attributes } = db.metadata.get(uid);
|
|
489
489
|
|
|
490
|
-
for (const attributeName
|
|
490
|
+
for (const attributeName of Object.keys(attributes)) {
|
|
491
491
|
const attribute = attributes[attributeName];
|
|
492
492
|
|
|
493
493
|
if (attribute.type !== 'relation' || !_.has(attributeName, data)) {
|
|
@@ -667,7 +667,7 @@ const createEntityManager = (db) => {
|
|
|
667
667
|
async deleteRelations(uid, id) {
|
|
668
668
|
const { attributes } = db.metadata.get(uid);
|
|
669
669
|
|
|
670
|
-
for (const attributeName
|
|
670
|
+
for (const attributeName of Object.keys(attributes)) {
|
|
671
671
|
const attribute = attributes[attributeName];
|
|
672
672
|
|
|
673
673
|
if (attribute.type !== 'relation') {
|
package/lib/lifecycles/index.js
CHANGED
|
@@ -54,7 +54,7 @@ const createLifecyclesProvider = (db) => {
|
|
|
54
54
|
* @param {Map<any, any>} states
|
|
55
55
|
*/
|
|
56
56
|
async run(action, uid, properties, states = new Map()) {
|
|
57
|
-
for (let i = 0; i < subscribers.length; i
|
|
57
|
+
for (let i = 0; i < subscribers.length; i += 1) {
|
|
58
58
|
const subscriber = subscribers[i];
|
|
59
59
|
if (typeof subscriber === 'function') {
|
|
60
60
|
const state = states.get(subscriber) || {};
|
|
@@ -8,7 +8,7 @@ const { fromRow } = require('./transform');
|
|
|
8
8
|
const getRootLevelPopulate = (meta) => {
|
|
9
9
|
const populate = {};
|
|
10
10
|
|
|
11
|
-
for (const attributeName
|
|
11
|
+
for (const attributeName of Object.keys(meta.attributes)) {
|
|
12
12
|
const attribute = meta.attributes[attributeName];
|
|
13
13
|
if (attribute.type === 'relation') {
|
|
14
14
|
populate[attributeName] = true;
|
|
@@ -72,7 +72,7 @@ const processPopulate = (populate, ctx) => {
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
const finalPopulate = {};
|
|
75
|
-
for (const key
|
|
75
|
+
for (const key of Object.keys(populateMap)) {
|
|
76
76
|
const attribute = meta.attributes[key];
|
|
77
77
|
|
|
78
78
|
if (!attribute) {
|
|
@@ -119,7 +119,7 @@ const applyPopulate = async (results, populate, ctx) => {
|
|
|
119
119
|
return results;
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
for (const key
|
|
122
|
+
for (const key of Object.keys(populate)) {
|
|
123
123
|
const attribute = meta.attributes[key];
|
|
124
124
|
const targetMeta = db.metadata.get(attribute.target);
|
|
125
125
|
|
|
@@ -540,7 +540,7 @@ const applyPopulate = async (results, populate, ctx) => {
|
|
|
540
540
|
}, {});
|
|
541
541
|
|
|
542
542
|
const map = {};
|
|
543
|
-
for (const type
|
|
543
|
+
for (const type of Object.keys(idsByType)) {
|
|
544
544
|
const ids = idsByType[type];
|
|
545
545
|
|
|
546
546
|
// type was removed but still in morph relation
|
|
@@ -604,7 +604,7 @@ const applyPopulate = async (results, populate, ctx) => {
|
|
|
604
604
|
}, {});
|
|
605
605
|
|
|
606
606
|
const map = {};
|
|
607
|
-
for (const type
|
|
607
|
+
for (const type of Object.keys(idsByType)) {
|
|
608
608
|
const ids = idsByType[type];
|
|
609
609
|
|
|
610
610
|
// type was removed but still in morph relation
|
|
@@ -76,7 +76,7 @@ const processAttributeWhere = (attribute, where, operator = '$eq') => {
|
|
|
76
76
|
|
|
77
77
|
const filters = {};
|
|
78
78
|
|
|
79
|
-
for (const key
|
|
79
|
+
for (const key of Object.keys(where)) {
|
|
80
80
|
const value = where[key];
|
|
81
81
|
|
|
82
82
|
if (!isOperator(key)) {
|
|
@@ -119,7 +119,7 @@ const processWhere = (where, ctx) => {
|
|
|
119
119
|
const filters = {};
|
|
120
120
|
|
|
121
121
|
// for each key in where
|
|
122
|
-
for (const key
|
|
122
|
+
for (const key of Object.keys(where)) {
|
|
123
123
|
const value = where[key];
|
|
124
124
|
|
|
125
125
|
// if operator $and $or then loop over them
|
|
@@ -27,7 +27,13 @@ const createQueryBuilder = (uid, db) => {
|
|
|
27
27
|
};
|
|
28
28
|
|
|
29
29
|
let counter = 0;
|
|
30
|
-
const getAlias = () =>
|
|
30
|
+
const getAlias = () => {
|
|
31
|
+
const alias = `t${counter}`;
|
|
32
|
+
|
|
33
|
+
counter += 1;
|
|
34
|
+
|
|
35
|
+
return alias;
|
|
36
|
+
};
|
|
31
37
|
|
|
32
38
|
return {
|
|
33
39
|
alias: getAlias(),
|
package/lib/schema/builder.js
CHANGED
|
@@ -316,7 +316,7 @@ const createHelpers = (db) => {
|
|
|
316
316
|
debug(`Creating column ${addedColumn.name}`);
|
|
317
317
|
|
|
318
318
|
if (addedColumn.type === 'increments' && !db.dialect.canAddIncrements()) {
|
|
319
|
-
tableBuilder.integer(addedColumn.name).unsigned()
|
|
319
|
+
tableBuilder.integer(addedColumn.name).unsigned();
|
|
320
320
|
tableBuilder.primary(addedColumn.name);
|
|
321
321
|
} else {
|
|
322
322
|
createColumn(tableBuilder, addedColumn);
|
package/lib/schema/schema.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/database",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.0-beta.0",
|
|
4
4
|
"description": "Strapi's database layer",
|
|
5
5
|
"homepage": "https://strapi.io",
|
|
6
6
|
"bugs": {
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"umzug": "3.1.1"
|
|
40
40
|
},
|
|
41
41
|
"engines": {
|
|
42
|
-
"node": ">=14.19.1 <=
|
|
42
|
+
"node": ">=14.19.1 <=18.x.x",
|
|
43
43
|
"npm": ">=6.0.0"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "cae16f7f259fa4473a55e8fea57839cda98f34ae"
|
|
46
46
|
}
|