<commit_before>/*

Default mutations

*/

import { registerCallback, newMutator, editMutator, removeMutator, Utils, Connectors } from 'meteor/vulcan:lib';
import Users from 'meteor/vulcan:users';

export const getDefaultMutations = (collectionName, options = {}) => {

  // register callbacks for documentation purposes
  registerCollectionCallbacks(collectionName);

  return {

    // mutation for inserting a new document

    new: {
      
      name: `${collectionName}New`,
      
      description: `Mutation for inserting new ${collectionName} documents`,

      // check function called on a user to see if they can perform the operation
      check(user, document) {
        if (options.newCheck) {
          return options.newCheck(user, document);
        }
        // if user is not logged in, disallow operation
        if (!user) return false;
        // else, check if they can perform "foo.new" operation (e.g. "movies.new")
        return Users.canDo(user, `${collectionName.toLowerCase()}.new`);
      },
      
      async mutation(root, {document}, context) {
        
        const collection = context[collectionName];<commit_msg>Allow guests to create document as a default<commit_after>/*

Default mutations

*/

import { registerCallback, newMutator, editMutator, removeMutator, Utils, Connectors } from 'meteor/vulcan:lib';
import Users from 'meteor/vulcan:users';

export const getDefaultMutations = (collectionName, options = {}) => {

  // register callbacks for documentation purposes
  registerCollectionCallbacks(collectionName);

  return {

    // mutation for inserting a new document

    new: {
      
      name: `${collectionName}New`,
      
      description: `Mutation for inserting new ${collectionName} documents`,

      // check function called on a user to see if they can perform the operation
      check(user, document) {
        if (options.newCheck) {
          return options.newCheck(user, document);
        }
        // check if they can perform "foo.new" operation (e.g. "movies.new")
        return Users.canDo(user, `${collectionName.toLowerCase()}.new`);
      },
      
      async mutation(root, {document}, context) {
        
        const collection = context[collectionName];
{'fraction_non_alphanumeric': 0.10437109723461195, 'fraction_numerical': 0.0, 'mean_word_length': 2.962897526501767, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1558632', 'n_tokens_mistral': 608, 'n_tokens_neox': 595, 'n_words': 187}