Skip to content

Commit f88c396

Browse files
authored
Merge pull request #26 from jhomarolo/main
feat: change findById return
2 parents 4559cf8 + a0c6d69 commit f88c396

File tree

8 files changed

+1820
-178
lines changed

8 files changed

+1820
-178
lines changed

README.md

+25-3
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,17 @@ const ret = await repo.find({ filter: { stringTest: ["aString"] } })
193193
You also can use the method find to use the mongoDB [native parameters](https://www.mongodb.com/docs/manual/reference/method/db.collection.find/)
194194

195195
```javascript
196+
const { ObjectId } = require('mongodb')
197+
196198
const repo = new ItemRepository(injection)
197-
const ret = await repo.find({ _id : { $in : [`4323fefwed4234`, '3432d23232dfff'] } } )
199+
const ret = await repo.find({ _id : { $in : [ObjectId('4323fefwed4234'), ObjectId('3432d23232dfff')] } } )
200+
```
201+
202+
```javascript
203+
const { ObjectId } = require('mongodb')
204+
205+
const repo = new ItemRepository(injection)
206+
const ret = await repo.find({ _id : { $in : [ObjectId('4323fefwed4234'), ObjectId('3432d23232dfff')] } } )
198207
```
199208

200209
- `findAll`
@@ -209,14 +218,27 @@ const ret = await repo.find({ } )
209218
### `findByID`
210219
Find entities by IDs
211220

212-
Format: `.findByID(id)` where `id` is a ObjectId string, this will be changed to _id automaticaly
221+
Format: `.findByID(id)` where `id` is a ObjectId string or array, this will be changed to _id automaticaly
213222

214-
Return: Entity
223+
Return: Entity array
215224

216225
```javascript
217226
const repo = new ItemRepository(injection)
218227
const ret = await repo.findByID('60edc25fc39277307ca9a7ff')
219228
```
229+
or
230+
```javascript
231+
232+
const ids = [
233+
'60edc25fc39277307ca9a7ff',
234+
'80edd25fc39272307ca9a712',
235+
]
236+
237+
const repo = new ItemRepository(injection)
238+
const ret = await repo.findByID(ids)
239+
```
240+
241+
220242

221243
### `insert`
222244

0 commit comments

Comments
 (0)