(appId, collectionName, document)
| 1002 | } |
| 1003 | |
| 1004 | function _save(appId, collectionName, document) { |
| 1005 | const deferredMain = q.defer(); |
| 1006 | try { |
| 1007 | if (document._isModified) { |
| 1008 | delete document._isModified; |
| 1009 | } |
| 1010 | if (document._modifiedColumns) { |
| 1011 | delete document._modifiedColumns; |
| 1012 | } |
| 1013 | document = _serialize(document); |
| 1014 | // column key array to track sub documents. |
| 1015 | obj.document._update(appId, collectionName, document).then((doc) => { |
| 1016 | doc = _deserialize(doc); |
| 1017 | deferredMain.resolve(doc); |
| 1018 | }, (err) => { |
| 1019 | winston.log('error', err); |
| 1020 | deferredMain.reject(err); |
| 1021 | }); |
| 1022 | } catch (err) { |
| 1023 | winston.log('error', { |
| 1024 | error: String(err), |
| 1025 | stack: new Error().stack, |
| 1026 | }); |
| 1027 | deferred.reject(err); |
| 1028 | } |
| 1029 | return deferredMain.promise; |
| 1030 | } |
| 1031 | |
| 1032 | function _serialize(document) { |
| 1033 | try { |
no test coverage detected