I connected to sync gate way via Api ,but I don't know how to filter some data and use them in my laravel project.
2 Answers
You are not filtering by channel in the syncgateway config, the filtering is the outcome of the sync-function, but it is more of a passive result of attaching a channel to a document. I have no idea which version you are using because your question lacks it, however configuration is pretty straight forward.
you basically have 2 options of attaching a channel to a document, the second is overriding the first: 1. don't have any sync function in the config file and just rely on a "channels" property, that property will make the document sync to the appropriate channels. for example:
{ "name": "Duke", "lastName": "Nukem", "channels": ["DukeNukem","Duke"] }
2. Have a sync function in the config file: For the document: { "name": "Duke", "lastName": "Nukem" }
you might have that sync function that will do the same:
function(doc, oldDoc){
if (doc.name && doc.lastName) {
channel(doc.name);
channel(doc.name + doc.lastName);
}
}
please note that you will have to grant permission to the user to able to see a channel.
in the client side you would need that user with the permission, and if you are not filtering for a channel - you will get the docs whenever you sync.
please read more here

- 575
- 4
- 14
Here is a Swift example on the client side on how to use the "channels" to route data:
let manager = CBLManager()
let database = try! manager.databaseNamed(dbName)
let pull = self.database.createPullReplication(url)
// We need to sync channels
pull.channels = ["somechannels"]
pull.start()
A concrete example on a Store
management application, every documents belong to a Store would be saved with channels contain the storeID
.
On the client side, when syncing we will put the storeID
inside channels
so that the sync will get only the documents belong to that Store
. (we are using the default sync function)
Note that, there are security concern that you need to take into consideration, read more here.

- 583
- 1
- 7
- 14