@cheetah.js/orm 0.1.125 → 0.1.127

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.
@@ -159,6 +159,7 @@ class Repository {
159
159
  async count(where) {
160
160
  return this.createQueryBuilder()
161
161
  .count()
162
+ .setStrategy('joined')
162
163
  .where(where || {})
163
164
  .executeCount();
164
165
  }
@@ -188,7 +188,8 @@ async function loadStatementsFromMigrations(options) {
188
188
  if (files.length < 1) {
189
189
  return [];
190
190
  }
191
- return extractStatementsFromFiles(files);
191
+ const orderedFiles = sortMigrationFiles(files);
192
+ return extractStatementsFromFiles(orderedFiles);
192
193
  }
193
194
  async function resolveMigrationPatterns(connection) {
194
195
  if (connection.migrationPath) {
@@ -272,6 +273,9 @@ function extractStatements(payload) {
272
273
  const matches = payload.match(/(CREATE\s+(?:TABLE|TYPE|INDEX|SCHEMA)[\s\S]*?;|ALTER\s+TABLE[\s\S]*?\bADD\b[\s\S]*?;)/gi) ?? [];
273
274
  return matches.map((statement) => statement.replace(/\s+/g, ' ').trim());
274
275
  }
276
+ function sortMigrationFiles(files) {
277
+ return [...files].sort((first, second) => path_1.default.basename(first).localeCompare(path_1.default.basename(second), undefined, { numeric: true }));
278
+ }
275
279
  async function prepareSchema(context, schema) {
276
280
  await context.executeSql(buildCreateSchemaStatement(schema));
277
281
  await ensureSearchPath(context, schema);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cheetah.js/orm",
3
- "version": "0.1.125",
3
+ "version": "0.1.127",
4
4
  "description": "A simple ORM for Cheetah.js",
5
5
  "type": "commonjs",
6
6
  "main": "dist/index.js",
@@ -55,5 +55,5 @@
55
55
  "bun",
56
56
  "value-object"
57
57
  ],
58
- "gitHead": "b93f774dc0f732549b22d724616e683819683b80"
58
+ "gitHead": "7f4a3c6b72f57fe1c34200015025ef14a33dad5a"
59
59
  }