@strapi/database 4.26.1 → 4.26.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/dist/index.js CHANGED
@@ -20,8 +20,7 @@ const knex = require("knex");
20
20
  const SqliteClient = require("knex/lib/dialects/sqlite3/index");
21
21
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
22
22
  function _interopNamespace(e) {
23
- if (e && e.__esModule)
24
- return e;
23
+ if (e && e.__esModule) return e;
25
24
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
26
25
  if (e) {
27
26
  for (const k in e) {
@@ -1918,8 +1917,7 @@ const createOneToOne = (attributeName, attribute, meta, metadata) => {
1918
1917
  } else {
1919
1918
  createJoinColum(metadata, {
1920
1919
  attribute,
1921
- attributeName,
1922
- meta
1920
+ attributeName
1923
1921
  });
1924
1922
  }
1925
1923
  }
@@ -1948,8 +1946,7 @@ const createManyToOne = (attributeName, attribute, meta, metadata) => {
1948
1946
  } else {
1949
1947
  createJoinColum(metadata, {
1950
1948
  attribute,
1951
- attributeName,
1952
- meta
1949
+ attributeName
1953
1950
  });
1954
1951
  }
1955
1952
  };
@@ -3415,17 +3412,17 @@ const applyPopulate = async (results, populate, ctx) => {
3415
3412
  case "morphOne":
3416
3413
  case "morphMany": {
3417
3414
  const targetMeta = db.metadata.get(attribute.target);
3418
- const input = { attribute, attributeName, results, populateValue, targetMeta, isCount };
3415
+ const input = { attribute, attributeName, results, populateValue, targetMeta };
3419
3416
  await morphX(input, ctx);
3420
3417
  break;
3421
3418
  }
3422
3419
  case "morphToMany": {
3423
- const input = { attribute, attributeName, results, populateValue, isCount };
3420
+ const input = { attribute, attributeName, results, populateValue };
3424
3421
  await morphToMany(input, ctx);
3425
3422
  break;
3426
3423
  }
3427
3424
  case "morphToOne": {
3428
- const input = { attribute, attributeName, results, populateValue, isCount };
3425
+ const input = { attribute, attributeName, results, populateValue };
3429
3426
  await morphToOne(input, ctx);
3430
3427
  break;
3431
3428
  }
@@ -4670,8 +4667,7 @@ const cleanOrderColumns = async ({
4670
4667
  }
4671
4668
  };
4672
4669
  const updateInverseOrderColumn = async () => {
4673
- if (!hasInverseOrderColumn(attribute) || _.isEmpty(inverseRelIds))
4674
- return;
4670
+ if (!hasInverseOrderColumn(attribute) || _.isEmpty(inverseRelIds)) return;
4675
4671
  const selectRowsToOrder = (joinTableName) => db.connection(joinTableName).select("id").rowNumber("inv_order", inverseOrderColumnName, inverseJoinColumn.name).where(inverseJoinColumn.name, "in", inverseRelIds).toSQL();
4676
4672
  switch (strapi.db.dialect.client) {
4677
4673
  case "mysql": {
@@ -4810,8 +4806,7 @@ const sortConnectArray = (connectArr, initialArr = [], strictSort = true) => {
4810
4806
  ...mapper
4811
4807
  };
4812
4808
  }, {});
4813
- if (!needsSorting)
4814
- return connectArr;
4809
+ if (!needsSorting) return connectArr;
4815
4810
  const computeRelation = (relation, relationsSeenInBranch) => {
4816
4811
  const adjacentRelId = relation.position?.before || relation.position?.after;
4817
4812
  const adjacentRelation = mappedRelations[adjacentRelId];
@@ -4918,8 +4913,7 @@ const relationsOrderer = (initArr, idColumn, orderColumn, strict) => {
4918
4913
  */
4919
4914
  getOrderMap() {
4920
4915
  return ___default$1.default(computedRelations).groupBy("order").reduce((acc, relations) => {
4921
- if (relations[0]?.init)
4922
- return acc;
4916
+ if (relations[0]?.init) return acc;
4923
4917
  relations.forEach((relation, idx) => {
4924
4918
  acc[relation.id] = Math.floor(relation.order) + (idx + 1) / (relations.length + 1);
4925
4919
  });
@@ -5722,8 +5716,7 @@ const createEntityManager = (db) => {
5722
5716
  }
5723
5717
  continue;
5724
5718
  }
5725
- if (attribute.relation === "morphToOne")
5726
- ;
5719
+ if (attribute.relation === "morphToOne") ;
5727
5720
  if (attribute.relation === "morphToMany") {
5728
5721
  const { joinTable } = attribute;
5729
5722
  const { joinColumn } = joinTable;
@@ -6033,8 +6026,7 @@ const createLifecyclesProvider = (db) => {
6033
6026
  * @param {Map<any, any>} states
6034
6027
  */
6035
6028
  async run(action, uid, properties, states = /* @__PURE__ */ new Map()) {
6036
- if (isLifecycleHooksDisabled)
6037
- return states;
6029
+ if (isLifecycleHooksDisabled) return states;
6038
6030
  for (let i = 0; i < subscribers.length; i += 1) {
6039
6031
  const subscriber = subscribers[i];
6040
6032
  if (typeof subscriber === "function") {
@@ -6211,8 +6203,7 @@ const getLinksWithoutMappedBy = (db) => {
6211
6203
  };
6212
6204
  const isLinkTableEmpty = async (db, linkTableName) => {
6213
6205
  const exists = await db.getSchemaConnection().hasTable(linkTableName);
6214
- if (!exists)
6215
- return true;
6206
+ if (!exists) return true;
6216
6207
  const result = await db.getConnection().from(linkTableName).count("* as count");
6217
6208
  return Number(result[0].count) === 0;
6218
6209
  };
@@ -6233,8 +6224,7 @@ const validateBidirectionalRelations = async (db) => {
6233
6224
  process.emitWarning(
6234
6225
  `Error on attribute "${relation.inversedBy}" in model "${invContentType.singularName}" (${invContentType.uid}). Please modify your ${invContentType.singularName} schema by renaming the key "inversedBy" to "mappedBy". Ex: { "inversedBy": "${invRelation.inversedBy}" } -> { "mappedBy": "${invRelation.inversedBy}" }`
6235
6226
  );
6236
- } else
6237
- ;
6227
+ } else ;
6238
6228
  }
6239
6229
  };
6240
6230
  const validateRelations = async (db) => {