@strapi/database 4.9.0-beta.2 → 4.9.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/.eslintignore ADDED
@@ -0,0 +1,2 @@
1
+ node_modules/
2
+ .eslintrc.js
package/.eslintrc.js ADDED
@@ -0,0 +1,4 @@
1
+ module.exports = {
2
+ root: true,
3
+ extends: ['custom/back'],
4
+ };
package/jest.config.js CHANGED
@@ -1,10 +1,5 @@
1
1
  'use strict';
2
2
 
3
- const baseConfig = require('../../../jest.base-config');
4
- const pkg = require('./package.json');
5
-
6
3
  module.exports = {
7
- ...baseConfig,
8
- displayName: (pkg.strapi && pkg.strapi.name) || pkg.name,
9
- roots: [__dirname],
4
+ preset: '../../../jest-preset.unit.js',
10
5
  };
@@ -268,9 +268,12 @@ const createEntityManager = (db) => {
268
268
  throw new Error('Nothing to insert');
269
269
  }
270
270
 
271
- await this.createQueryBuilder(uid).insert(dataToInsert).execute();
271
+ const createdEntries = await this.createQueryBuilder(uid).insert(dataToInsert).execute();
272
272
 
273
- const result = { count: data.length };
273
+ const result = {
274
+ count: data.length,
275
+ ids: createdEntries.map((entry) => (typeof entry === 'object' ? entry?.id : entry)),
276
+ };
274
277
 
275
278
  await db.lifecycles.run('afterCreateMany', uid, { params, result }, states);
276
279
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strapi/database",
3
- "version": "4.9.0-beta.2",
3
+ "version": "4.9.0",
4
4
  "description": "Strapi's database layer",
5
5
  "homepage": "https://strapi.io",
6
6
  "bugs": {
@@ -28,7 +28,9 @@
28
28
  "lib": "./lib"
29
29
  },
30
30
  "scripts": {
31
- "test:unit": "jest --verbose"
31
+ "test:unit": "jest",
32
+ "test:unit:watch": "jest --watch",
33
+ "lint": "eslint ."
32
34
  },
33
35
  "dependencies": {
34
36
  "date-fns": "2.29.3",
@@ -43,5 +45,5 @@
43
45
  "node": ">=14.19.1 <=18.x.x",
44
46
  "npm": ">=6.0.0"
45
47
  },
46
- "gitHead": "d893ead642592a15a95fefb71c544aaabe4db20b"
48
+ "gitHead": "ffe3f4621ccc968ce56fda9a8317ec30d4bad205"
47
49
  }
@@ -0,0 +1,55 @@
1
+ 'use strict';
2
+
3
+ // Test an API with all the possible filed types and simple filterings (no deep filtering, no relations)
4
+ const { createStrapiInstance } = require('../../../../test/helpers/strapi');
5
+ const { createTestBuilder } = require('../../../../test/helpers/builder');
6
+
7
+ const builder = createTestBuilder();
8
+ let strapi;
9
+
10
+ const testCT = {
11
+ displayName: 'test',
12
+ singularName: 'test',
13
+ pluralName: 'tests',
14
+ kind: 'collectionType',
15
+ attributes: {
16
+ name: {
17
+ type: 'string',
18
+ },
19
+ },
20
+ };
21
+
22
+ const fixtures = {
23
+ test: [
24
+ {
25
+ name: 'Hugo LLORIS',
26
+ },
27
+ {
28
+ name: 'Samuel UMTITI',
29
+ },
30
+ {
31
+ name: 'Lucas HERNANDEZ',
32
+ },
33
+ ],
34
+ };
35
+
36
+ describe('Deep Filtering API', () => {
37
+ beforeAll(async () => {
38
+ await builder.addContentType(testCT).build();
39
+
40
+ strapi = await createStrapiInstance();
41
+ });
42
+
43
+ afterAll(async () => {
44
+ await strapi.destroy();
45
+ await builder.cleanup();
46
+ });
47
+
48
+ test('Return an array of ids on createMany', async () => {
49
+ const res = await strapi.db.query('api::test.test').createMany({ data: fixtures.test });
50
+
51
+ expect(res).toMatchObject({ count: expect.any(Number) });
52
+ expect(Array.isArray(res.ids)).toBe(true);
53
+ expect(res.ids.length > 0).toBe(true);
54
+ });
55
+ });