(saveOptions, cb)
| 101 | } |
| 102 | }; |
| 103 | var saveInstance = function (saveOptions, cb) { |
| 104 | // what this condition means: |
| 105 | // - If the instance is in state mode |
| 106 | // - AND it's not an association that is asking it to save |
| 107 | // -> return has already saved |
| 108 | if (instance_saving && saveOptions.saveAssociations !== false) { |
| 109 | return cb(null, instance); |
| 110 | } |
| 111 | instance_saving = true; |
| 112 | |
| 113 | handleValidations(function (err) { |
| 114 | if (err) { |
| 115 | return saveError(cb, err); |
| 116 | } |
| 117 | |
| 118 | if (opts.is_new) { |
| 119 | waitHooks([ "beforeCreate", "beforeSave" ], function (err) { |
| 120 | if (err) { |
| 121 | return saveError(cb, err); |
| 122 | } |
| 123 | |
| 124 | return saveNew(saveOptions, getInstanceData(), cb); |
| 125 | }); |
| 126 | } else { |
| 127 | waitHooks([ "beforeSave" ], function (err) { |
| 128 | if (err) { |
| 129 | return saveError(cb, err); |
| 130 | } |
| 131 | |
| 132 | return savePersisted(saveOptions, getInstanceData(), cb); |
| 133 | }); |
| 134 | } |
| 135 | }); |
| 136 | }; |
| 137 | var runAfterSaveActions = function (cb, create, err) { |
| 138 | instance_saving = false; |
| 139 |
no test coverage detected