@twin.org/entity-storage-connector-mongodb 0.0.2-next.1 → 0.0.2-next.10

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/README.md CHANGED
@@ -13,7 +13,7 @@ npm install @twin.org/entity-storage-connector-mongodb
13
13
  The tests developed are functional tests and need an instance of MongoDb up and running. To run MongoDb locally:
14
14
 
15
15
  ```sh
16
- docker run -p 27017:27017 --name twin-entity-storage-mongodb --hostname mongo -d mongo
16
+ docker run -p 27500:27017 --name twin-entity-storage-mongodb --hostname mongo -d mongo
17
17
  ```
18
18
 
19
19
  Afterwards you can run the tests as follows:
@@ -2,7 +2,6 @@
2
2
 
3
3
  var core = require('@twin.org/core');
4
4
  var entity = require('@twin.org/entity');
5
- var loggingModels = require('@twin.org/logging-models');
6
5
  var mongodb = require('mongodb');
7
6
 
8
7
  // Copyright 2024 IOTA Stiftung.
@@ -12,14 +11,14 @@ var mongodb = require('mongodb');
12
11
  */
13
12
  class MongoDbEntityStorageConnector {
14
13
  /**
15
- * Limit the number of entities when finding.
16
- * @internal
14
+ * Runtime name for the class.
17
15
  */
18
- static _PAGE_SIZE = 40;
16
+ static CLASS_NAME = "MongoDbEntityStorageConnector";
19
17
  /**
20
- * Runtime name for the class.
18
+ * Limit the number of entities when finding.
19
+ * @internal
21
20
  */
22
- CLASS_NAME = "MongoDbEntityStorageConnector";
21
+ static _DEFAULT_LIMIT = 40;
23
22
  /**
24
23
  * The schema for the entity.
25
24
  * @internal
@@ -40,70 +39,67 @@ class MongoDbEntityStorageConnector {
40
39
  * @param options The options for the connector.
41
40
  */
42
41
  constructor(options) {
43
- core.Guards.object(this.CLASS_NAME, "options", options);
44
- core.Guards.stringValue(this.CLASS_NAME, "options.entitySchema", options.entitySchema);
45
- core.Guards.object(this.CLASS_NAME, "options.config", options.config);
46
- core.Guards.stringValue(this.CLASS_NAME, "options.config.host", options.config.host);
47
- core.Guards.stringValue(this.CLASS_NAME, "options.config.database", options.config.database);
48
- core.Guards.stringValue(this.CLASS_NAME, "options.config.collection", options.config.collection);
42
+ core.Guards.object(MongoDbEntityStorageConnector.CLASS_NAME, "options", options);
43
+ core.Guards.stringValue(MongoDbEntityStorageConnector.CLASS_NAME, "options.entitySchema", options.entitySchema);
44
+ core.Guards.object(MongoDbEntityStorageConnector.CLASS_NAME, "options.config", options.config);
45
+ core.Guards.stringValue(MongoDbEntityStorageConnector.CLASS_NAME, "options.config.host", options.config.host);
46
+ core.Guards.stringValue(MongoDbEntityStorageConnector.CLASS_NAME, "options.config.database", options.config.database);
47
+ core.Guards.stringValue(MongoDbEntityStorageConnector.CLASS_NAME, "options.config.collection", options.config.collection);
49
48
  this._entitySchema = entity.EntitySchemaFactory.get(options.entitySchema);
50
49
  this._config = options.config;
51
50
  this._client = new mongodb.MongoClient(this.createConnectionConfig());
52
51
  }
53
52
  /**
54
53
  * Initialize the MongoDb environment.
55
- * @param nodeLoggingConnectorType Optional type of the logging connector.
54
+ * @param nodeLoggingComponentType Optional type of the logging component.
56
55
  * @returns A promise that resolves to a boolean indicating success.
57
56
  */
58
- async bootstrap(nodeLoggingConnectorType) {
59
- const nodeLogging = loggingModels.LoggingConnectorFactory.getIfExists(nodeLoggingConnectorType ?? "node-logging");
57
+ async bootstrap(nodeLoggingComponentType) {
58
+ const nodeLogging = core.ComponentFactory.getIfExists(nodeLoggingComponentType);
60
59
  try {
61
60
  await this._client.connect();
62
61
  await nodeLogging?.log({
63
62
  level: "info",
64
- source: this.CLASS_NAME,
63
+ source: MongoDbEntityStorageConnector.CLASS_NAME,
65
64
  ts: Date.now(),
66
65
  message: "databaseCreating",
67
66
  data: {
68
- database: this._config.database
67
+ databaseName: this._config.database
69
68
  }
70
69
  });
71
70
  // Create the database if it does not exist
72
71
  this._client.db(this._config.database);
73
72
  await nodeLogging?.log({
74
73
  level: "info",
75
- source: this.CLASS_NAME,
74
+ source: MongoDbEntityStorageConnector.CLASS_NAME,
76
75
  ts: Date.now(),
77
76
  message: "databaseExists",
78
77
  data: {
79
- database: this._config.database
78
+ databaseName: this._config.database
80
79
  }
81
80
  });
82
81
  await this.getCollection();
83
82
  await nodeLogging?.log({
84
83
  level: "info",
85
- source: this.CLASS_NAME,
84
+ source: MongoDbEntityStorageConnector.CLASS_NAME,
86
85
  ts: Date.now(),
87
86
  message: "collectionExists",
88
87
  data: {
89
- collection: this._config.collection
88
+ collectionName: this._config.collection
90
89
  }
91
90
  });
92
91
  }
93
92
  catch (error) {
94
- const errors = error instanceof AggregateError ? error.errors : [error];
95
- for (const err of errors) {
96
- await nodeLogging?.log({
97
- level: "error",
98
- source: this.CLASS_NAME,
99
- ts: Date.now(),
100
- message: "databaseCreateFailed",
101
- error: core.BaseError.fromError(err),
102
- data: {
103
- database: this._config.database
104
- }
105
- });
106
- }
93
+ await nodeLogging?.log({
94
+ level: "error",
95
+ source: MongoDbEntityStorageConnector.CLASS_NAME,
96
+ ts: Date.now(),
97
+ message: "databaseCreateFailed",
98
+ error: core.BaseError.fromError(error),
99
+ data: {
100
+ databaseName: this._config.database
101
+ }
102
+ });
107
103
  return false;
108
104
  }
109
105
  return true;
@@ -123,7 +119,7 @@ class MongoDbEntityStorageConnector {
123
119
  * @returns The object if it can be found or undefined.
124
120
  */
125
121
  async get(id, secondaryIndex, conditions) {
126
- core.Guards.stringValue(this.CLASS_NAME, "id", id);
122
+ core.Guards.stringValue(MongoDbEntityStorageConnector.CLASS_NAME, "id", id);
127
123
  try {
128
124
  const primaryKey = entity.EntitySchemaHelper.getPrimaryKey(this.getSchema());
129
125
  const query = core.Is.empty(secondaryIndex)
@@ -139,7 +135,7 @@ class MongoDbEntityStorageConnector {
139
135
  return result;
140
136
  }
141
137
  catch (err) {
142
- throw new core.GeneralError(this.CLASS_NAME, "getFailed", {
138
+ throw new core.GeneralError(MongoDbEntityStorageConnector.CLASS_NAME, "getFailed", {
143
139
  id
144
140
  }, err);
145
141
  }
@@ -151,7 +147,7 @@ class MongoDbEntityStorageConnector {
151
147
  * @returns The id of the entity.
152
148
  */
153
149
  async set(entity$1, conditions) {
154
- core.Guards.object(this.CLASS_NAME, "entity", entity$1);
150
+ core.Guards.object(MongoDbEntityStorageConnector.CLASS_NAME, "entity", entity$1);
155
151
  entity.EntitySchemaHelper.validateEntity(entity$1, this.getSchema());
156
152
  const primaryKey = entity.EntitySchemaHelper.getPrimaryKey(this.getSchema());
157
153
  const id = entity$1[primaryKey.property];
@@ -166,7 +162,7 @@ class MongoDbEntityStorageConnector {
166
162
  await collection.findOneAndUpdate(filter, { $set: entity$1 }, { upsert: true });
167
163
  }
168
164
  catch (err) {
169
- throw new core.GeneralError(this.CLASS_NAME, "setFailed", {
165
+ throw new core.GeneralError(MongoDbEntityStorageConnector.CLASS_NAME, "setFailed", {
170
166
  id
171
167
  }, err);
172
168
  }
@@ -178,7 +174,7 @@ class MongoDbEntityStorageConnector {
178
174
  * @returns Nothing.
179
175
  */
180
176
  async remove(id, conditions) {
181
- core.Guards.stringValue(this.CLASS_NAME, "id", id);
177
+ core.Guards.stringValue(MongoDbEntityStorageConnector.CLASS_NAME, "id", id);
182
178
  try {
183
179
  const primaryKey = entity.EntitySchemaHelper.getPrimaryKey(this.getSchema());
184
180
  const query = { [primaryKey.property]: id };
@@ -191,7 +187,7 @@ class MongoDbEntityStorageConnector {
191
187
  await collection.deleteOne(query);
192
188
  }
193
189
  catch (err) {
194
- throw new core.GeneralError(this.CLASS_NAME, "removeFailed", { id }, err);
190
+ throw new core.GeneralError(MongoDbEntityStorageConnector.CLASS_NAME, "removeFailed", { id }, err);
195
191
  }
196
192
  }
197
193
  /**
@@ -199,13 +195,13 @@ class MongoDbEntityStorageConnector {
199
195
  * @param conditions The conditions to match for the entities.
200
196
  * @param sortProperties The optional sort order.
201
197
  * @param properties The optional properties to return, defaults to all.
202
- * @param cursor The cursor to request the next page of entities.
203
- * @param pageSize The suggested number of entities to return in each chunk, in some scenarios can return a different amount.
198
+ * @param cursor The cursor to request the next chunk of entities.
199
+ * @param limit The suggested number of entities to return in each chunk, in some scenarios can return a different amount.
204
200
  * @returns All the entities for the storage matching the conditions,
205
201
  * and a cursor which can be used to request more entities.
206
202
  */
207
- async query(conditions, sortProperties, properties, cursor, pageSize) {
208
- const returnSize = pageSize ?? MongoDbEntityStorageConnector._PAGE_SIZE;
203
+ async query(conditions, sortProperties, properties, cursor, limit) {
204
+ const returnSize = limit ?? MongoDbEntityStorageConnector._DEFAULT_LIMIT;
209
205
  const filter = {};
210
206
  if (conditions) {
211
207
  this.buildQueryParameters("", conditions, filter);
@@ -225,6 +221,8 @@ class MongoDbEntityStorageConnector {
225
221
  const cursorValue = cursor ? Number(cursor) : 0;
226
222
  const collection = await this.getCollection();
227
223
  const entities = await collection
224
+ // False positive, this is not an array find call
225
+ // eslint-disable-next-line unicorn/no-array-callback-reference
228
226
  ?.find(filter, { projection })
229
227
  .sort(sort)
230
228
  .skip(cursorValue)
@@ -329,7 +327,7 @@ class MongoDbEntityStorageConnector {
329
327
  case entity.ComparisonOperator.Includes:
330
328
  return { $elemMatch: { $eq: value } };
331
329
  default:
332
- throw new core.GeneralError(this.CLASS_NAME, "unsupportedComparisonOperator", { comparison });
330
+ throw new core.GeneralError(MongoDbEntityStorageConnector.CLASS_NAME, "unsupportedComparisonOperator", { comparison });
333
331
  }
334
332
  }
335
333
  }
@@ -1,6 +1,5 @@
1
- import { Guards, BaseError, Is, GeneralError } from '@twin.org/core';
1
+ import { Guards, ComponentFactory, BaseError, Is, GeneralError } from '@twin.org/core';
2
2
  import { EntitySchemaFactory, EntitySchemaHelper, LogicalOperator, ComparisonOperator } from '@twin.org/entity';
3
- import { LoggingConnectorFactory } from '@twin.org/logging-models';
4
3
  import { MongoClient } from 'mongodb';
5
4
 
6
5
  // Copyright 2024 IOTA Stiftung.
@@ -10,14 +9,14 @@ import { MongoClient } from 'mongodb';
10
9
  */
11
10
  class MongoDbEntityStorageConnector {
12
11
  /**
13
- * Limit the number of entities when finding.
14
- * @internal
12
+ * Runtime name for the class.
15
13
  */
16
- static _PAGE_SIZE = 40;
14
+ static CLASS_NAME = "MongoDbEntityStorageConnector";
17
15
  /**
18
- * Runtime name for the class.
16
+ * Limit the number of entities when finding.
17
+ * @internal
19
18
  */
20
- CLASS_NAME = "MongoDbEntityStorageConnector";
19
+ static _DEFAULT_LIMIT = 40;
21
20
  /**
22
21
  * The schema for the entity.
23
22
  * @internal
@@ -38,70 +37,67 @@ class MongoDbEntityStorageConnector {
38
37
  * @param options The options for the connector.
39
38
  */
40
39
  constructor(options) {
41
- Guards.object(this.CLASS_NAME, "options", options);
42
- Guards.stringValue(this.CLASS_NAME, "options.entitySchema", options.entitySchema);
43
- Guards.object(this.CLASS_NAME, "options.config", options.config);
44
- Guards.stringValue(this.CLASS_NAME, "options.config.host", options.config.host);
45
- Guards.stringValue(this.CLASS_NAME, "options.config.database", options.config.database);
46
- Guards.stringValue(this.CLASS_NAME, "options.config.collection", options.config.collection);
40
+ Guards.object(MongoDbEntityStorageConnector.CLASS_NAME, "options", options);
41
+ Guards.stringValue(MongoDbEntityStorageConnector.CLASS_NAME, "options.entitySchema", options.entitySchema);
42
+ Guards.object(MongoDbEntityStorageConnector.CLASS_NAME, "options.config", options.config);
43
+ Guards.stringValue(MongoDbEntityStorageConnector.CLASS_NAME, "options.config.host", options.config.host);
44
+ Guards.stringValue(MongoDbEntityStorageConnector.CLASS_NAME, "options.config.database", options.config.database);
45
+ Guards.stringValue(MongoDbEntityStorageConnector.CLASS_NAME, "options.config.collection", options.config.collection);
47
46
  this._entitySchema = EntitySchemaFactory.get(options.entitySchema);
48
47
  this._config = options.config;
49
48
  this._client = new MongoClient(this.createConnectionConfig());
50
49
  }
51
50
  /**
52
51
  * Initialize the MongoDb environment.
53
- * @param nodeLoggingConnectorType Optional type of the logging connector.
52
+ * @param nodeLoggingComponentType Optional type of the logging component.
54
53
  * @returns A promise that resolves to a boolean indicating success.
55
54
  */
56
- async bootstrap(nodeLoggingConnectorType) {
57
- const nodeLogging = LoggingConnectorFactory.getIfExists(nodeLoggingConnectorType ?? "node-logging");
55
+ async bootstrap(nodeLoggingComponentType) {
56
+ const nodeLogging = ComponentFactory.getIfExists(nodeLoggingComponentType);
58
57
  try {
59
58
  await this._client.connect();
60
59
  await nodeLogging?.log({
61
60
  level: "info",
62
- source: this.CLASS_NAME,
61
+ source: MongoDbEntityStorageConnector.CLASS_NAME,
63
62
  ts: Date.now(),
64
63
  message: "databaseCreating",
65
64
  data: {
66
- database: this._config.database
65
+ databaseName: this._config.database
67
66
  }
68
67
  });
69
68
  // Create the database if it does not exist
70
69
  this._client.db(this._config.database);
71
70
  await nodeLogging?.log({
72
71
  level: "info",
73
- source: this.CLASS_NAME,
72
+ source: MongoDbEntityStorageConnector.CLASS_NAME,
74
73
  ts: Date.now(),
75
74
  message: "databaseExists",
76
75
  data: {
77
- database: this._config.database
76
+ databaseName: this._config.database
78
77
  }
79
78
  });
80
79
  await this.getCollection();
81
80
  await nodeLogging?.log({
82
81
  level: "info",
83
- source: this.CLASS_NAME,
82
+ source: MongoDbEntityStorageConnector.CLASS_NAME,
84
83
  ts: Date.now(),
85
84
  message: "collectionExists",
86
85
  data: {
87
- collection: this._config.collection
86
+ collectionName: this._config.collection
88
87
  }
89
88
  });
90
89
  }
91
90
  catch (error) {
92
- const errors = error instanceof AggregateError ? error.errors : [error];
93
- for (const err of errors) {
94
- await nodeLogging?.log({
95
- level: "error",
96
- source: this.CLASS_NAME,
97
- ts: Date.now(),
98
- message: "databaseCreateFailed",
99
- error: BaseError.fromError(err),
100
- data: {
101
- database: this._config.database
102
- }
103
- });
104
- }
91
+ await nodeLogging?.log({
92
+ level: "error",
93
+ source: MongoDbEntityStorageConnector.CLASS_NAME,
94
+ ts: Date.now(),
95
+ message: "databaseCreateFailed",
96
+ error: BaseError.fromError(error),
97
+ data: {
98
+ databaseName: this._config.database
99
+ }
100
+ });
105
101
  return false;
106
102
  }
107
103
  return true;
@@ -121,7 +117,7 @@ class MongoDbEntityStorageConnector {
121
117
  * @returns The object if it can be found or undefined.
122
118
  */
123
119
  async get(id, secondaryIndex, conditions) {
124
- Guards.stringValue(this.CLASS_NAME, "id", id);
120
+ Guards.stringValue(MongoDbEntityStorageConnector.CLASS_NAME, "id", id);
125
121
  try {
126
122
  const primaryKey = EntitySchemaHelper.getPrimaryKey(this.getSchema());
127
123
  const query = Is.empty(secondaryIndex)
@@ -137,7 +133,7 @@ class MongoDbEntityStorageConnector {
137
133
  return result;
138
134
  }
139
135
  catch (err) {
140
- throw new GeneralError(this.CLASS_NAME, "getFailed", {
136
+ throw new GeneralError(MongoDbEntityStorageConnector.CLASS_NAME, "getFailed", {
141
137
  id
142
138
  }, err);
143
139
  }
@@ -149,7 +145,7 @@ class MongoDbEntityStorageConnector {
149
145
  * @returns The id of the entity.
150
146
  */
151
147
  async set(entity, conditions) {
152
- Guards.object(this.CLASS_NAME, "entity", entity);
148
+ Guards.object(MongoDbEntityStorageConnector.CLASS_NAME, "entity", entity);
153
149
  EntitySchemaHelper.validateEntity(entity, this.getSchema());
154
150
  const primaryKey = EntitySchemaHelper.getPrimaryKey(this.getSchema());
155
151
  const id = entity[primaryKey.property];
@@ -164,7 +160,7 @@ class MongoDbEntityStorageConnector {
164
160
  await collection.findOneAndUpdate(filter, { $set: entity }, { upsert: true });
165
161
  }
166
162
  catch (err) {
167
- throw new GeneralError(this.CLASS_NAME, "setFailed", {
163
+ throw new GeneralError(MongoDbEntityStorageConnector.CLASS_NAME, "setFailed", {
168
164
  id
169
165
  }, err);
170
166
  }
@@ -176,7 +172,7 @@ class MongoDbEntityStorageConnector {
176
172
  * @returns Nothing.
177
173
  */
178
174
  async remove(id, conditions) {
179
- Guards.stringValue(this.CLASS_NAME, "id", id);
175
+ Guards.stringValue(MongoDbEntityStorageConnector.CLASS_NAME, "id", id);
180
176
  try {
181
177
  const primaryKey = EntitySchemaHelper.getPrimaryKey(this.getSchema());
182
178
  const query = { [primaryKey.property]: id };
@@ -189,7 +185,7 @@ class MongoDbEntityStorageConnector {
189
185
  await collection.deleteOne(query);
190
186
  }
191
187
  catch (err) {
192
- throw new GeneralError(this.CLASS_NAME, "removeFailed", { id }, err);
188
+ throw new GeneralError(MongoDbEntityStorageConnector.CLASS_NAME, "removeFailed", { id }, err);
193
189
  }
194
190
  }
195
191
  /**
@@ -197,13 +193,13 @@ class MongoDbEntityStorageConnector {
197
193
  * @param conditions The conditions to match for the entities.
198
194
  * @param sortProperties The optional sort order.
199
195
  * @param properties The optional properties to return, defaults to all.
200
- * @param cursor The cursor to request the next page of entities.
201
- * @param pageSize The suggested number of entities to return in each chunk, in some scenarios can return a different amount.
196
+ * @param cursor The cursor to request the next chunk of entities.
197
+ * @param limit The suggested number of entities to return in each chunk, in some scenarios can return a different amount.
202
198
  * @returns All the entities for the storage matching the conditions,
203
199
  * and a cursor which can be used to request more entities.
204
200
  */
205
- async query(conditions, sortProperties, properties, cursor, pageSize) {
206
- const returnSize = pageSize ?? MongoDbEntityStorageConnector._PAGE_SIZE;
201
+ async query(conditions, sortProperties, properties, cursor, limit) {
202
+ const returnSize = limit ?? MongoDbEntityStorageConnector._DEFAULT_LIMIT;
207
203
  const filter = {};
208
204
  if (conditions) {
209
205
  this.buildQueryParameters("", conditions, filter);
@@ -223,6 +219,8 @@ class MongoDbEntityStorageConnector {
223
219
  const cursorValue = cursor ? Number(cursor) : 0;
224
220
  const collection = await this.getCollection();
225
221
  const entities = await collection
222
+ // False positive, this is not an array find call
223
+ // eslint-disable-next-line unicorn/no-array-callback-reference
226
224
  ?.find(filter, { projection })
227
225
  .sort(sort)
228
226
  .skip(cursorValue)
@@ -327,7 +325,7 @@ class MongoDbEntityStorageConnector {
327
325
  case ComparisonOperator.Includes:
328
326
  return { $elemMatch: { $eq: value } };
329
327
  default:
330
- throw new GeneralError(this.CLASS_NAME, "unsupportedComparisonOperator", { comparison });
328
+ throw new GeneralError(MongoDbEntityStorageConnector.CLASS_NAME, "unsupportedComparisonOperator", { comparison });
331
329
  }
332
330
  }
333
331
  }
@@ -8,10 +8,10 @@ export interface IMongoDbEntityStorageConnectorConstructorOptions {
8
8
  */
9
9
  entitySchema: string;
10
10
  /**
11
- * The type of logging connector to use.
11
+ * The type of logging component to use.
12
12
  * @default logging
13
13
  */
14
- loggingConnectorType?: string;
14
+ loggingComponentType?: string;
15
15
  /**
16
16
  * The configuration for the connector.
17
17
  */
@@ -8,7 +8,7 @@ export declare class MongoDbEntityStorageConnector<T = unknown> implements IEnti
8
8
  /**
9
9
  * Runtime name for the class.
10
10
  */
11
- readonly CLASS_NAME: string;
11
+ static readonly CLASS_NAME: string;
12
12
  /**
13
13
  * Create a new instance of MongoDbEntityStorageConnector.
14
14
  * @param options The options for the connector.
@@ -16,10 +16,10 @@ export declare class MongoDbEntityStorageConnector<T = unknown> implements IEnti
16
16
  constructor(options: IMongoDbEntityStorageConnectorConstructorOptions);
17
17
  /**
18
18
  * Initialize the MongoDb environment.
19
- * @param nodeLoggingConnectorType Optional type of the logging connector.
19
+ * @param nodeLoggingComponentType Optional type of the logging component.
20
20
  * @returns A promise that resolves to a boolean indicating success.
21
21
  */
22
- bootstrap(nodeLoggingConnectorType?: string): Promise<boolean>;
22
+ bootstrap(nodeLoggingComponentType?: string): Promise<boolean>;
23
23
  /**
24
24
  * Get the schema for the entities.
25
25
  * @returns The schema for the entities.
@@ -61,15 +61,15 @@ export declare class MongoDbEntityStorageConnector<T = unknown> implements IEnti
61
61
  * @param conditions The conditions to match for the entities.
62
62
  * @param sortProperties The optional sort order.
63
63
  * @param properties The optional properties to return, defaults to all.
64
- * @param cursor The cursor to request the next page of entities.
65
- * @param pageSize The suggested number of entities to return in each chunk, in some scenarios can return a different amount.
64
+ * @param cursor The cursor to request the next chunk of entities.
65
+ * @param limit The suggested number of entities to return in each chunk, in some scenarios can return a different amount.
66
66
  * @returns All the entities for the storage matching the conditions,
67
67
  * and a cursor which can be used to request more entities.
68
68
  */
69
69
  query(conditions?: EntityCondition<T>, sortProperties?: {
70
70
  property: keyof T;
71
71
  sortDirection: SortDirection;
72
- }[], properties?: (keyof T)[], cursor?: string, pageSize?: number): Promise<{
72
+ }[], properties?: (keyof T)[], cursor?: string, limit?: number): Promise<{
73
73
  entities: Partial<T>[];
74
74
  cursor?: string;
75
75
  }>;
package/docs/changelog.md CHANGED
@@ -1,5 +1,149 @@
1
1
  # @twin.org/entity-storage-connector-mongodb - Changelog
2
2
 
3
+ ## [0.0.2-next.10](https://github.com/twinfoundation/entity-storage/compare/entity-storage-connector-mongodb-v0.0.2-next.9...entity-storage-connector-mongodb-v0.0.2-next.10) (2025-10-09)
4
+
5
+
6
+ ### Features
7
+
8
+ * add validate-locales ([e66ef0d](https://github.com/twinfoundation/entity-storage/commit/e66ef0de26ca2f82b3fe89bb5c7a15a0978a9644))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @twin.org/entity-storage-models bumped from 0.0.2-next.9 to 0.0.2-next.10
16
+ * devDependencies
17
+ * @twin.org/entity-storage-connector-memory bumped from 0.0.2-next.9 to 0.0.2-next.10
18
+
19
+ ## [0.0.2-next.9](https://github.com/twinfoundation/entity-storage/compare/entity-storage-connector-mongodb-v0.0.2-next.8...entity-storage-connector-mongodb-v0.0.2-next.9) (2025-10-02)
20
+
21
+
22
+ ### Miscellaneous Chores
23
+
24
+ * **entity-storage-connector-mongodb:** Synchronize repo versions
25
+
26
+
27
+ ### Dependencies
28
+
29
+ * The following workspace dependencies were updated
30
+ * dependencies
31
+ * @twin.org/entity-storage-models bumped from 0.0.2-next.8 to 0.0.2-next.9
32
+ * devDependencies
33
+ * @twin.org/entity-storage-connector-memory bumped from 0.0.2-next.8 to 0.0.2-next.9
34
+
35
+ ## [0.0.2-next.8](https://github.com/twinfoundation/entity-storage/compare/entity-storage-connector-mongodb-v0.0.2-next.7...entity-storage-connector-mongodb-v0.0.2-next.8) (2025-08-29)
36
+
37
+
38
+ ### Features
39
+
40
+ * eslint migration to flat config ([f033b64](https://github.com/twinfoundation/entity-storage/commit/f033b64984c0e6a8129d929c9dd816dcc1b8dab0))
41
+
42
+
43
+ ### Dependencies
44
+
45
+ * The following workspace dependencies were updated
46
+ * dependencies
47
+ * @twin.org/entity-storage-models bumped from 0.0.2-next.7 to 0.0.2-next.8
48
+ * devDependencies
49
+ * @twin.org/entity-storage-connector-memory bumped from 0.0.2-next.7 to 0.0.2-next.8
50
+
51
+ ## [0.0.2-next.7](https://github.com/twinfoundation/entity-storage/compare/entity-storage-connector-mongodb-v0.0.2-next.6...entity-storage-connector-mongodb-v0.0.2-next.7) (2025-08-20)
52
+
53
+
54
+ ### Features
55
+
56
+ * logging naming consistency ([f99d12d](https://github.com/twinfoundation/entity-storage/commit/f99d12dea04b6d4f2b5632ff5473e9ec7d5f9055))
57
+
58
+
59
+ ### Dependencies
60
+
61
+ * The following workspace dependencies were updated
62
+ * dependencies
63
+ * @twin.org/entity-storage-models bumped from 0.0.2-next.6 to 0.0.2-next.7
64
+ * devDependencies
65
+ * @twin.org/entity-storage-connector-memory bumped from 0.0.2-next.6 to 0.0.2-next.7
66
+
67
+ ## [0.0.2-next.6](https://github.com/twinfoundation/entity-storage/compare/entity-storage-connector-mongodb-v0.0.2-next.5...entity-storage-connector-mongodb-v0.0.2-next.6) (2025-08-19)
68
+
69
+
70
+ ### Features
71
+
72
+ * update framework core ([b59a380](https://github.com/twinfoundation/entity-storage/commit/b59a380bb7fba2b43610f69074dcdee24a4737da))
73
+
74
+
75
+ ### Dependencies
76
+
77
+ * The following workspace dependencies were updated
78
+ * dependencies
79
+ * @twin.org/entity-storage-models bumped from 0.0.2-next.5 to 0.0.2-next.6
80
+ * devDependencies
81
+ * @twin.org/entity-storage-connector-memory bumped from 0.0.2-next.5 to 0.0.2-next.6
82
+
83
+ ## [0.0.2-next.5](https://github.com/twinfoundation/entity-storage/compare/entity-storage-connector-mongodb-v0.0.2-next.4...entity-storage-connector-mongodb-v0.0.2-next.5) (2025-08-11)
84
+
85
+
86
+ ### Miscellaneous Chores
87
+
88
+ * **entity-storage-connector-mongodb:** Synchronize repo versions
89
+
90
+
91
+ ### Dependencies
92
+
93
+ * The following workspace dependencies were updated
94
+ * dependencies
95
+ * @twin.org/entity-storage-models bumped from 0.0.2-next.4 to 0.0.2-next.5
96
+ * devDependencies
97
+ * @twin.org/entity-storage-connector-memory bumped from 0.0.2-next.4 to 0.0.2-next.5
98
+
99
+ ## [0.0.2-next.4](https://github.com/twinfoundation/entity-storage/compare/entity-storage-connector-mongodb-v0.0.2-next.3...entity-storage-connector-mongodb-v0.0.2-next.4) (2025-08-08)
100
+
101
+
102
+ ### Miscellaneous Chores
103
+
104
+ * **entity-storage-connector-mongodb:** Synchronize repo versions
105
+
106
+
107
+ ### Dependencies
108
+
109
+ * The following workspace dependencies were updated
110
+ * dependencies
111
+ * @twin.org/entity-storage-models bumped from 0.0.2-next.3 to 0.0.2-next.4
112
+ * devDependencies
113
+ * @twin.org/entity-storage-connector-memory bumped from 0.0.2-next.3 to 0.0.2-next.4
114
+
115
+ ## [0.0.2-next.3](https://github.com/twinfoundation/entity-storage/compare/entity-storage-connector-mongodb-v0.0.2-next.2...entity-storage-connector-mongodb-v0.0.2-next.3) (2025-07-25)
116
+
117
+
118
+ ### Miscellaneous Chores
119
+
120
+ * **entity-storage-connector-mongodb:** Synchronize repo versions
121
+
122
+
123
+ ### Dependencies
124
+
125
+ * The following workspace dependencies were updated
126
+ * dependencies
127
+ * @twin.org/entity-storage-models bumped from 0.0.2-next.2 to 0.0.2-next.3
128
+ * devDependencies
129
+ * @twin.org/entity-storage-connector-memory bumped from 0.0.2-next.2 to 0.0.2-next.3
130
+
131
+ ## [0.0.2-next.2](https://github.com/twinfoundation/entity-storage/compare/entity-storage-connector-mongodb-v0.0.2-next.1...entity-storage-connector-mongodb-v0.0.2-next.2) (2025-07-24)
132
+
133
+
134
+ ### Features
135
+
136
+ * synchronised storage ([#44](https://github.com/twinfoundation/entity-storage/issues/44)) ([94e10e2](https://github.com/twinfoundation/entity-storage/commit/94e10e26d1feec801449dc04af7a9757ac7495ff))
137
+
138
+
139
+ ### Dependencies
140
+
141
+ * The following workspace dependencies were updated
142
+ * dependencies
143
+ * @twin.org/entity-storage-models bumped from 0.0.2-next.1 to 0.0.2-next.2
144
+ * devDependencies
145
+ * @twin.org/entity-storage-connector-memory bumped from 0.0.2-next.1 to 0.0.2-next.2
146
+
3
147
  ## [0.0.2-next.1](https://github.com/twinfoundation/entity-storage/compare/entity-storage-connector-mongodb-v0.0.2-next.0...entity-storage-connector-mongodb-v0.0.2-next.1) (2025-07-17)
4
148
 
5
149
 
@@ -36,29 +36,25 @@ The options for the connector.
36
36
 
37
37
  ### CLASS\_NAME
38
38
 
39
- > `readonly` **CLASS\_NAME**: `string`
39
+ > `readonly` `static` **CLASS\_NAME**: `string`
40
40
 
41
41
  Runtime name for the class.
42
42
 
43
- #### Implementation of
44
-
45
- `IEntityStorageConnector.CLASS_NAME`
46
-
47
43
  ## Methods
48
44
 
49
45
  ### bootstrap()
50
46
 
51
- > **bootstrap**(`nodeLoggingConnectorType?`): `Promise`\<`boolean`\>
47
+ > **bootstrap**(`nodeLoggingComponentType?`): `Promise`\<`boolean`\>
52
48
 
53
49
  Initialize the MongoDb environment.
54
50
 
55
51
  #### Parameters
56
52
 
57
- ##### nodeLoggingConnectorType?
53
+ ##### nodeLoggingComponentType?
58
54
 
59
55
  `string`
60
56
 
61
- Optional type of the logging connector.
57
+ Optional type of the logging component.
62
58
 
63
59
  #### Returns
64
60
 
@@ -194,7 +190,7 @@ Nothing.
194
190
 
195
191
  ### query()
196
192
 
197
- > **query**(`conditions?`, `sortProperties?`, `properties?`, `cursor?`, `pageSize?`): `Promise`\<\{ `entities`: `Partial`\<`T`\>[]; `cursor?`: `string`; \}\>
193
+ > **query**(`conditions?`, `sortProperties?`, `properties?`, `cursor?`, `limit?`): `Promise`\<\{ `entities`: `Partial`\<`T`\>[]; `cursor?`: `string`; \}\>
198
194
 
199
195
  Find all the entities which match the conditions.
200
196
 
@@ -222,9 +218,9 @@ The optional properties to return, defaults to all.
222
218
 
223
219
  `string`
224
220
 
225
- The cursor to request the next page of entities.
221
+ The cursor to request the next chunk of entities.
226
222
 
227
- ##### pageSize?
223
+ ##### limit?
228
224
 
229
225
  `number`
230
226
 
@@ -12,11 +12,11 @@ The schema for the entity.
12
12
 
13
13
  ***
14
14
 
15
- ### loggingConnectorType?
15
+ ### loggingComponentType?
16
16
 
17
- > `optional` **loggingConnectorType**: `string`
17
+ > `optional` **loggingComponentType**: `string`
18
18
 
19
- The type of logging connector to use.
19
+ The type of logging component to use.
20
20
 
21
21
  #### Default
22
22
 
package/locales/en.json CHANGED
@@ -11,11 +11,8 @@
11
11
  "setFailed": "Unable to set entity \"{id}\"",
12
12
  "getFailed": "Unable to get entity \"{id}\"",
13
13
  "removeFailed": "Unable to remove entity \"{id}\"",
14
- "queryFailed": "The query failed",
15
- "comparisonNotSupported": "Comparison operator \"{comparison}\" is not supported",
16
- "conditionalNotSupported": "Conditional operator \"{operator}\" is not supported",
17
- "sortSingle": "You can only sort by a single property",
18
- "sortNotIndexed": "The property \"{property}\" is not indexed and cannot be used for sorting"
14
+ "databaseCreateFailed": "The database creation failed for \"{databaseName}\"",
15
+ "unsupportedComparisonOperator": "Comparison operator \"{comparison}\" is not supported"
19
16
  }
20
17
  }
21
18
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/entity-storage-connector-mongodb",
3
- "version": "0.0.2-next.1",
3
+ "version": "0.0.2-next.10",
4
4
  "description": "Entity Storage connector implementation using MongoDb storage",
5
5
  "repository": {
6
6
  "type": "git",
@@ -16,10 +16,10 @@
16
16
  "dependencies": {
17
17
  "@twin.org/core": "next",
18
18
  "@twin.org/entity": "next",
19
- "@twin.org/entity-storage-models": "0.0.2-next.1",
19
+ "@twin.org/entity-storage-models": "0.0.2-next.10",
20
20
  "@twin.org/logging-models": "next",
21
21
  "@twin.org/nameof": "next",
22
- "mongodb": "6.17.0"
22
+ "mongodb": "6.20.0"
23
23
  },
24
24
  "main": "./dist/cjs/index.cjs",
25
25
  "module": "./dist/esm/index.mjs",
@@ -38,5 +38,24 @@
38
38
  "dist/types",
39
39
  "locales",
40
40
  "docs"
41
- ]
41
+ ],
42
+ "keywords": [
43
+ "twin",
44
+ "trade",
45
+ "iota",
46
+ "framework",
47
+ "blockchain",
48
+ "entity-storage",
49
+ "entity",
50
+ "storage",
51
+ "persistence",
52
+ "database",
53
+ "connector",
54
+ "adapter",
55
+ "integration"
56
+ ],
57
+ "bugs": {
58
+ "url": "git+https://github.com/twinfoundation/entity-storage/issues"
59
+ },
60
+ "homepage": "https://twindev.org"
42
61
  }