Skip to content

Commit 9a1abc5

Browse files
committed
Add bucket method that returns an objects version
1 parent 6b3b251 commit 9a1abc5

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/simperium/bucket.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ Bucket.prototype.update = function( id, data, options, callback ) {
3131
return this.store.update( id, data, this.isIndexing, callback );
3232
};
3333

34+
Bucket.prototype.getVersion = function( id, callback ) {
35+
callback( null, 0 );
36+
};
37+
3438
Bucket.prototype.touch = function( id, callback ) {
3539
return this.store.get( id, ( e, object ) => {
3640
if ( e ) return callback( e );

src/simperium/channel.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,20 @@ export default function Channel( appid, access_token, bucket, store ) {
293293
collectionRevisions( channel, id, callback );
294294
};
295295

296+
bucket.getVersion = function( id, callback ) {
297+
store.get( id ).then(
298+
( ghost ) => {
299+
var version = 0;
300+
if ( ghost && ghost.version ) {
301+
version = ghost.version;
302+
}
303+
callback( null, version );
304+
},
305+
// callback with error if promise fails
306+
callback
307+
);
308+
};
309+
296310
bucketEvents
297311
.on( 'update', internal.diffAndSend.bind( this ) )
298312
.on( 'remove', internal.removeAndSend.bind( this ) );

0 commit comments

Comments
 (0)