Cheatsheet

Mutations

Mutators

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
await createMutator({
collection,
data,
currentUser,
validate,
context,
});

await updateMutator({
documentId
collection,
data,
currentUser,
validate,
context,
});

await deleteMutator({
documentId,
collection,
currentUser,
validate,
context,
});

Callbacks

Properties

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// create
const properties = {
data,
originalData: clone(data),
currentUser,
collection,
context,
schema,
};

// update
const properties = {
data,
originalData: clone(data),
document,
originalDocument: oldDocument,
currentUser,
collection,
context,
schema,
};

// delete
const properties = {
document,
currentUser,
collection,
context,
schema
};

Mutation Callbacks

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
createCollection({
callbacks {
create: {
validate: [(validationErrors, properties) => { return validationErrors; }],
before: [(document, properties) => { return document; }],
after: [(document, properties) => { return document; }],
async: [(properties) => { /* no return value */ }],
}
update: {
validate: [(validationErrors, properties) => { return validationErrors; }],
before: [(data, properties) => { return data; }],
after: [(document, properties) => { return document; }],
async: [(properties) => { /* no return value */ }],
}
delete: {
validate: [(validationErrors, properties) => { return validationErrors; }],
before: [(document, properties) => { return document; }],
after: [(document, properties) => { return document; }],
async: [(properties) => { /* no return value */ }],
}
}
});

Field Callbacks

const schema = {
  field: {
    onCreate: (properties) => { return fieldValue },
    onUpdate: (properties) => { return fieldValue },
    onDelete: (properties) => { // return nothing }
  }
}
Edit on GitHub