Cloud Defense Logo

Products

Solutions

Company

Book A Live Demo

Top 3 Examples of "strapi-bookshelf in functional component" in JavaScript

Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'strapi-bookshelf' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.

// Otherwise if it's a "many-to-many" relationship.

      // Save the relationship.
      const relationship = models[details.collection].attributes[details.via];

      // Construct relation table name.
      const relationTable = _.map(_.sortBy([relationship, details], 'collection'), table => {
        return _.snakeCase(pluralize.plural(table.collection) + ' ' + pluralize.plural(table.via));
      }).join('__');

      // Force singular foreign key.
      relationship.attribute = pluralize.singular(relationship.collection);
      details.attribute = pluralize.singular(details.collection);

      // Define PK column.
      details.column = utilsBookShelf.getPK(modelName, undefined, models);
      relationship.column = utilsBookShelf.getPK(details.collection, undefined, models);

      // Avoid to create table both times.
      if (!rootModels.hasOwnProperty(relationTable) || !_.isEmpty(_.get(rootModels, relationTable + '.up.drop'))) {
        // Set objects
        if (_.isUndefined(_.get(models, relationTable + '.up.others'))) {
          _.set(rootModels, relationTable + '.up.others', '');
        }

        if (_.isUndefined(_.get(rootModels, relationTable + '.up.drop'))) {
          _.set(rootModels, relationTable + '.up.drop', '');
        }

        if (_.isUndefined(_.get(rootModels, relationTable + '.down.others'))) {
          _.set(rootModels, relationTable + '.down.others', '');
        }
}

    if (_.isEmpty(_.get(rootModels[modelName].attributes, attribute + '.delete'))) {
      _.set(rootModels[modelName].attributes, attribute + '.delete', {
        drop: '',
        others: ''
      });
    }

    // If it's a "one-to-one" relationship.
    if (infos.verbose === 'hasOne') {
      // Force singular foreign key.
      details.attribute = pluralize.singular(details.model);

      // Define PK column.
      details.column = utilsBookShelf.getPK(modelName, undefined, models);

      if (!toDrop) {
        tplRelationUp = fs.readFileSync(path.resolve(__dirname, '..', '..', 'templates', 'builder', 'relations', 'hasOne.template'), 'utf8');
        models[modelName].attributes[attribute].create.others += _.unescape(_.template(tplRelationUp)({
          tableName: modelName,
          attribute,
          details
        }));

        tplRelationDown = fs.readFileSync(path.resolve(__dirname, '..', '..', 'templates', 'builder', 'columns', 'dropColumn-unique.template'), 'utf8');
        models[modelName].attributes[attribute].delete.others += _.unescape(_.template(tplRelationDown)({
          tableName: modelName,
          attribute,
          details
        }));
      } else {
// Save the relationship.
      const relationship = models[details.collection].attributes[details.via];

      // Construct relation table name.
      const relationTable = _.map(_.sortBy([relationship, details], 'collection'), table => {
        return _.snakeCase(pluralize.plural(table.collection) + ' ' + pluralize.plural(table.via));
      }).join('__');

      // Force singular foreign key.
      relationship.attribute = pluralize.singular(relationship.collection);
      details.attribute = pluralize.singular(details.collection);

      // Define PK column.
      details.column = utilsBookShelf.getPK(modelName, undefined, models);
      relationship.column = utilsBookShelf.getPK(details.collection, undefined, models);

      // Avoid to create table both times.
      if (!rootModels.hasOwnProperty(relationTable) || !_.isEmpty(_.get(rootModels, relationTable + '.up.drop'))) {
        // Set objects
        if (_.isUndefined(_.get(models, relationTable + '.up.others'))) {
          _.set(rootModels, relationTable + '.up.others', '');
        }

        if (_.isUndefined(_.get(rootModels, relationTable + '.up.drop'))) {
          _.set(rootModels, relationTable + '.up.drop', '');
        }

        if (_.isUndefined(_.get(rootModels, relationTable + '.down.others'))) {
          _.set(rootModels, relationTable + '.down.others', '');
        }

Is your System Free of Underlying Vulnerabilities?
Find Out Now