Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updateAll API conflicts with the name by supporting ID queries #32

Merged
merged 4 commits into from
Jun 11, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/base.repo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,14 +235,12 @@ export class BaseRepository<T extends Model> {

/**
* Updates multiple documents that match a particular query
* @param query MongoDB query object or id string
* @param query MongoDB query object
* @param update Update onbject
*/
updateAll(query: string | object, update: any): Promise<T[]> {
const _query = this.getQuery(query);

updateAll(query: object, update: any): Promise<T[]> {
return new Promise((resolve, reject) => {
this.model.updateMany(_query, update, (err, result) => {
this.model.updateMany(query, update, (err, result) => {
if (err) return reject(err);
resolve(result);
});
Expand Down