Prerequisites
Mongoose version
7.0.3
Node.js version
18.16.0
MongoDB version
5.2.0
Operating system
macOS
Operating system version (i.e. 20.04, 11.3, 10)
No response
Issue
I have a LogModel defined using
import { getModelForClass, modelOptions } from '@typegoose/typegoose';
@modelOptions({ schemaOptions: { writeConcern: { w: 0 } } })
export class Log {...}
export const LogModel = getModelForClass(Log);
the write concern here is to speedup the log write requests.
Now I would like to remove the logs inside a transaction with other models, and the error is:
Cannot have explicit session with unacknowledged writes
await withTransaction(async (session) => {
...other removal
await LogModel.deleteMany({ user: user._id }, { session });
...other removal
});
I tried supply explicit write concern into the deleteMany query to override the setting in model, but same error occurs.
await withTransaction(async (session) => {
...other removal
await LogModel.deleteMany({ user: user._id }, { session, writeConcern: { w: 'majority', j: true } });
...other removal
});
so I think the deleteMany is not respecting the overriding options.
Prerequisites
Mongoose version
7.0.3
Node.js version
18.16.0
MongoDB version
5.2.0
Operating system
macOS
Operating system version (i.e. 20.04, 11.3, 10)
No response
Issue
I have a LogModel defined using
the write concern here is to speedup the log write requests.
Now I would like to remove the logs inside a transaction with other models, and the error is:
Cannot have explicit session with unacknowledged writesI tried supply explicit write concern into the deleteMany query to override the setting in model, but same error occurs.
so I think the deleteMany is not respecting the overriding options.