Skip to content

Commit 0b58b78

Browse files
committed
fix saving old snapshot
1 parent c642e17 commit 0b58b78

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

index.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,19 @@ var _ = require('lodash')
22
module.exports = function(backend) {
33
backend.hook = hook.bind(backend);
44
backend.onQuery = onQuery.bind(backend);
5+
6+
backend.use('apply', function(shareRequest, done) {
7+
console.log('apply', shareRequest.snapshot)
8+
const opData = shareRequest.op
9+
const snapshot = shareRequest.snapshot
10+
11+
if (!opData.create && !shareRequest.originalSnapshot){
12+
shareRequest.originalSnapshot = _.cloneDeep(snapshot)
13+
}
14+
15+
done()
16+
})
17+
518
};
619

720
function onQuery(collectionName, cb) {
@@ -20,16 +33,7 @@ function onQuery(collectionName, cb) {
2033
cb(shareRequest.query, session, next);
2134

2235
});
23-
backend.use('apply', function(shareRequest, done) {
24-
const opData = shareRequest.op
25-
const snapshot = shareRequest.snapshot
26-
27-
if (!opData.create && !shareRequest.originalSnapshot){
28-
shareRequest.originalSnapshot = _.cloneDeep(snapshot)
29-
}
3036

31-
done()
32-
})
3337
}
3438

3539

0 commit comments

Comments
 (0)