What are default extended attributes in a document and how do use it in sync gateway sync function

I was wondering what are those extended attributes that i can use in sync function? Do we have list of Xattr (extended attributes)?

I was reading documentation however not enough clarity on extended attributes. It say we can create our own extended attributes? are they available at bucket level or just and particular document level ? how do correlate them with sync gateway?

Extended attributes are used to associate app specific metadata with documents. Sync Gateway v1.5 leverages the Xattrs functionality to store sync metadata that would required for syncing documents with mobile clients. This is used for implementing shared bucket access.

This is available via subdocument extensions in language specific SDKs. The link has several code examples on how to add them.

At this point, the SGW has no visibility into user created XAttrs (only the sync metadata that I mentioned above that it adds )

I am interested in understanding your use case better - on why you would like the ability to access the xattr within the sync function.

Thank you for replying promptly! Ok, so User created Xattr are not available to SGW, fair enough; How do i leverage doc meta data in SGW? are you referring to Virtual Extended Attributes? I am assuming that can be accessible like “function(doc, oldDoc){ doc.$document … }”

The use case i was trying to work on is- --> , I don’t want to add “user” or “owner” or “creator” information as part document; I would like to access through some Xattr, what is alternative?

Possible use case is after authentication all subsequent requests contains authorization token/cookie, I would want to use that information to validate access or channel information.

One more question around sync function - Do we have any built in function which can access document meta data with in sync function?

like meta().id?

you can get id and rev via doc._id and doc._rev.