mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 10:01:40 -05:00
Backwards compatibility with documentId
This commit is contained in:
parent
f532addb0b
commit
7e67a441cd
1 changed files with 6 additions and 2 deletions
|
@ -144,13 +144,14 @@ export const createMutator = async ({ collection, document, data, currentUser, v
|
|||
}
|
||||
|
||||
|
||||
export const updateMutator = async ({ collection, selector, data, set = {}, unset = {}, currentUser, validate, context, document }) => {
|
||||
export const updateMutator = async ({ collection, documentId, selector, data, set = {}, unset = {}, currentUser, validate, context, document }) => {
|
||||
|
||||
const { collectionName, typeName } = collection.options;
|
||||
|
||||
const schema = collection.simpleSchema()._schema;
|
||||
|
||||
// OpenCRUD backwards compatibility
|
||||
selector = selector || { _id: documentId };
|
||||
data = data || modifierToData({ $set: set, $unset: unset });
|
||||
|
||||
if (isEmpty(selector)) {
|
||||
|
@ -265,7 +266,7 @@ export const updateMutator = async ({ collection, selector, data, set = {}, unse
|
|||
return { data: newDocument };
|
||||
}
|
||||
|
||||
export const deleteMutator = async ({ collection, selector, currentUser, validate, context, document }) => {
|
||||
export const deleteMutator = async ({ collection, documentId, selector, currentUser, validate, context, document }) => {
|
||||
|
||||
const { collectionName, typeName } = collection.options;
|
||||
|
||||
|
@ -276,6 +277,9 @@ export const deleteMutator = async ({ collection, selector, currentUser, validat
|
|||
|
||||
const schema = collection.simpleSchema()._schema;
|
||||
|
||||
// OpenCRUD backwards compatibility
|
||||
selector = selector || { _id: documentId };
|
||||
|
||||
if (isEmpty(selector)) {
|
||||
throw new Error(`Selector cannot be empty`);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue