Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -471,9 +471,8 @@ export const saveValidation = (validation) => {
'schema-validation-saved'
);
dataService.updateCollection(
namespace.database,
`${namespace.database}.${namespace.collection}`,
{
collMod: namespace.collection,
validator: savedValidation.validator,
validationAction: savedValidation.validationAction,
validationLevel: savedValidation.validationLevel
Expand Down
9 changes: 7 additions & 2 deletions packages/data-service/src/native-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1102,14 +1102,19 @@ class NativeClient extends EventEmitter {
*/
updateCollection(
ns: string,
flags: Document,
// Collection name to update that will be passed to the collMod command will
// be derived from the provided namespace, this is why we are explicitly
// prohibiting to pass collMod flag here
flags: Document & { collMod?: never },
callback: Callback<Document>
): void {
const collectionName = this._collectionName(ns);
const db = this.client.db(this._databaseName(ns));
// Order of arguments is important here, collMod is a command name and it
// should always be the first one in the object
const command = {
...flags,
collMod: collectionName,
...flags,
};
db.command(command, (error, result) => {
if (error) {
Expand Down