How do buckets work concerning Couchbase Mobile

Hello, just a quick question about the logistics of implementing couchbase in a mobile application.

I am going to use a basic example to illustrate my question. Lets say this application has many users. Each user has data describing there house/s, car/s, and boat/s. I am used to mongoDB here, so if I wanted to store this data I would have each user on the mobile side have 3 collections respectively with the appropriate documents describing each house/car/boat in the collection. Then all these documents would be pushed to the server that has 4 collections. Cars, Boats, houses, and users. So every users car would be in the car collection on the server.

If a bucket is the same as a collection, then using couchbase should have the same implementation (or similar). However I am having trouble finding an example that has buckets being used in couchbase mobile. I am wondering if this isn’t the case then what would I do to achieve the same affect? Would having a house database, car database, and boat database have the same affect on the mobile side? then I would sync these databases to buckets on the server? Can a bucket hold every users data for cars or would I need thousands of buckets.

You can create and work with multiple CBL database files, and you can replicate any of them to the server – I have not yet tried doing this at the same time myself. It’s up to your programming to keep them separate and manage what data goes into which database.

If you set channels on your user data then you can separate who gets which dataset replicated to the client. So you wouldn’t need thousands of buckets, you would need thousands of channels.

In Couchbase you’d store everything in the same server bucket, and define channels for access control, so each user sees only the documents relevant to them. The most likely way is to add an owner property to each document whose value is the user ID; that makes it very simple to create a channel named after the user ID containing that user’s documents.