actions/add.js
function createChild(customCb) {


        ChildModel.create(child).then(function(newChildRecord){
          if (req._sails.hooks.pubsub) {
            if (req.isSocket) {
              ChildModel.subscribe(req, newChildRecord);
              ChildModel.introduce(newChildRecord);
            }
            ChildModel.publishCreate(newChildRecord, !req.options.mirror && req);
          }
          // in case we have to create a child and link it to parent(M-M through scenario)
          // createChild function should return the instance to be linked
          // in the through model => customCb
          return (typeof customCb === 'function') ?
            customCb(null, newChildRecord[childPkAttr]) : cb(null, newChildRecord[childPkAttr]);
        }).catch(function(err){
          return cb(err);
        });
      }
function createChild(customCb) {


        ChildModel.create(child).then(function(newChildRecord){
          if (req._sails.hooks.pubsub) {
            if (req.isSocket) {
              ChildModel.subscribe(req, newChildRecord);
              ChildModel.introduce(newChildRecord);
            }
            ChildModel.publishCreate(newChildRecord, !req.options.mirror && req);
          }
          // in case we have to create a child and link it to parent(M-M through scenario)
          // createChild function should return the instance to be linked
          // in the through model => customCb
          return (typeof customCb === 'function') ?
            customCb(null, newChildRecord[childPkAttr]) : cb(null, newChildRecord[childPkAttr]);
        }).catch(function(err){
          return cb(err);
        });
      }
function createChild ( customCb ) { ChildModel . create ( child ) . then ( function ( newChildRecord ) { if ( req . _sails . hooks . pubsub ) { if ( req . isSocket ) { ChildModel . subscribe ( req , newChildRecord ) ; ChildModel . introduce ( newChildRecord ) ; } ChildModel . publishCreate ( newChildRecord , ! req . options . mirror && req ) ; } // in case we have to create a child and link it to parent(M-M through scenario) // createChild function should return the instance to be linked // in the through model => customCb return ( typeof customCb === 'function' ) ? customCb ( null , newChildRecord [ childPkAttr ] ) : cb ( null , newChildRecord [ childPkAttr ] ) ; } ) . catch ( function ( err ) { return cb ( err ) ; } ) ; }
Create a new instance and send out any required pubsub messages.
Create a new instance and send out any required pubsub messages .