alexandre-spieser / mongodb-generic-repository

An example of generic repository implementation using the MongoDB C# Sharp 2.0 driver (async)
MIT License
311 stars 84 forks source link

Is Upsert Possible? #28

Closed TraGicCode closed 4 years ago

TraGicCode commented 4 years ago

Hey,

Is Upsert possible on the repository currently? For Example, if i want to allow a single method to be called for both inserts AND updates? I tried using .UpdateOne() but that seems to not do this.

alexandre-spieser commented 4 years ago

Hello, no but you can easily implement your custom behaviour in a class repo inheriting from BaseMongoRepository, where the MongoDbContext gives you access to raw driver capabilities.

TraGicCode commented 4 years ago

Thanks @alexandre-spieser

H-Finch-404 commented 3 months ago

Is still this the case right now? If so, would you consider adding it to the library? Upsert is a pretty basic MongoDB/document db feature