Expiry is not working in syncgateway sync function

We tried to implement expiry function on a sync gateway which is backed by couch base. While posting the data we are getting following error.

The sync function is as shown below:-
function(doc, oldDoc)
{ expiry(doc.ExpiryDateEpoch); }

I even tried with expiry(“2018-07-06T17:00:00+01:00”) shown at https://developer.couchbase.com/documentation/mobile/1.4/guides/sync-gateway/sync-function-api-guide/index.html#expiry

but this too gave the same error. below is the error. If somebody got a working piece of sync function having expiry then please help.

Sync fn exception: ReferenceError: expiry is not defined;
– db.(*Database).getChannelsAndAccess() at crud.go:911
–> 500 Exception in JS sync function (28.8 ms)

CC:- @househippo

Pankaj Sharma

Which version of Sync Gateway are you using?

It looks like that feature wasn’t added until Sync Gateway 2.0:

https://github.com/couchbase/sync_gateway/issues/3015 (check the milestone)


SG 2.0 is GA today :slight_smile:

I am excited for SG 2.0 but the problem is we cant move to that as the production date is very near. We want to have this in 1.4.1. Please let us know what help I can be for the same.


I don’t know how much engineering resource it would take to back port.

Check out the release notes of SG 1.5.1 & 2.0.0
It might be worth upgrading.

If its a blocker for you try opening a support ticket at: https://support.couchbase.com

We’re not adding new features to 1.x products … only high priority bug-fixes.

No issues we have used 2.0 and its working fine.

I am using syncgateway 1.5.1. Looks like expiry feature is not added in 1.5.1.

From release notes , i can see expiry is added 1.5.
#3015 Set document expiry via Sync Function

2018-12-16T22:30:17.294-06:00 WARNING: Sync fn exception: ReferenceError: expiry is not defined; doc = map[_rev:1-01a8ecaee168c0a3856f89a380ba9ea3 _id:test ver:dafda type:pttHistory recipientId:stel+:test1 state:processed userId:test] – db.(*Database).getChannelsAndAccess() at crud.go:1199
2018-12-16T22:30:17.294-06:00 HTTP: #052: --> 500 Exception in JS sync function (1.4 ms)

That looks like a straight up typo. The linked ticket (3015) has nothing to do with expiry.