@pioneer-platform/default-mongo-v2 1.1.0 → 1.3.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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @pioneer-platform/default-mongo-v2
2
2
 
3
+ ## 1.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Automated minor version bump for all packages
8
+
9
+ ## 1.2.0
10
+
11
+ ### Minor Changes
12
+
13
+ - Automated minor version bump for all packages
14
+
3
15
  ## 1.1.0
4
16
 
5
17
  ### Minor Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pioneer-platform/default-mongo-v2",
3
- "version": "1.1.0",
3
+ "version": "1.3.0",
4
4
  "description": "Bun & ts-node compatible MongoDB client wrapper (no monk)",
5
5
  "main": "src/index.ts",
6
6
  "dependencies": {
package/src/index.ts CHANGED
@@ -83,30 +83,30 @@ class CollectionWrapper<T extends Document = Document> {
83
83
 
84
84
  // Find documents (returns array like monk)
85
85
  async find(query: Filter<T> = {}, options: FindOptions = {}): Promise<T[]> {
86
- return await this.collection.find(query, options).toArray();
86
+ return (await this.collection.find(query, options).toArray()) as T[];
87
87
  }
88
88
 
89
89
  // Find one document
90
90
  async findOne(query: Filter<T>): Promise<T | null> {
91
- return await this.collection.findOne(query);
91
+ return (await this.collection.findOne(query)) as T | null;
92
92
  }
93
93
 
94
94
  // Insert one document
95
95
  async insert(doc: Partial<T>): Promise<T> {
96
96
  const result = await this.collection.insertOne(doc as any);
97
- return { ...doc, _id: result.insertedId } as T;
97
+ return { ...doc, _id: result.insertedId } as unknown as T;
98
98
  }
99
99
 
100
100
  // Update documents
101
101
  async update(query: Filter<T>, update: UpdateFilter<T> | Partial<T>, options: any = {}): Promise<any> {
102
102
  const updateDoc = ('$set' in update || '$inc' in update || '$push' in update)
103
103
  ? update as UpdateFilter<T>
104
- : { $set: update };
104
+ : { $set: update } as UpdateFilter<T>;
105
105
 
106
106
  if (options.multi) {
107
- return await this.collection.updateMany(query, updateDoc);
107
+ return await this.collection.updateMany(query, updateDoc as any);
108
108
  } else {
109
- return await this.collection.updateOne(query, updateDoc);
109
+ return await this.collection.updateOne(query, updateDoc as any);
110
110
  }
111
111
  }
112
112