Skip to content

Commit 656025a

Browse files
authored
Merge pull request #23 from jhomarolo/main
feat: add native parameter to filters and improve the connection method
2 parents 6a93064 + 095b8bd commit 656025a

21 files changed

+10951
-168
lines changed

README.md

+10-5
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@ module.exports = async () => {
2323
if (dbInstance) {
2424
return new Promise((resolve) => resolve(dbInstance))
2525
}
26-
const client = await new MongoClient(config.connectionString, {
27-
useNewUrlParser: true,
28-
useUnifiedTopology: true
29-
}).connect()
26+
const client = await new MongoClient(config.connectionString).connect()
3027
dbInstance = client.db(config.databaseName)
3128
Logger.setLevel("debug") // set this if you want to debug all queries
3229
return dbInstance
@@ -48,7 +45,7 @@ class ItemRepository extends Repository {
4845
collection: 'aCollection',
4946
database,
5047
ids: ['id'],
51-
mongodb: await connection()
48+
mongodb: connection
5249
})
5350
}
5451

@@ -192,6 +189,14 @@ const repo = new ItemRepository(injection)
192189
const ret = await repo.find({ filter: { stringTest: ["aString"] } })
193190
```
194191

192+
- `find with native parameters`
193+
You also can use the method find to use the mongoDB [native parameters](https://www.mongodb.com/docs/manual/reference/method/db.collection.find/)
194+
195+
```javascript
196+
const repo = new ItemRepository(injection)
197+
const ret = await repo.find({ _id : { $in : [`4323fefwed4234`, '3432d23232dfff'] } } )
198+
```
199+
195200
### `findByID`
196201
Find entities by IDs
197202

0 commit comments

Comments
 (0)