(Spring Couchbase) Single tenant Dynamic bucket and scope choosing

Our proposed architecture to go for One Bucket per Organization and child organization will be isolated by scope. We re using the Spring Couchbase as data layer> Does it provide capability to dynamically choose database? We will be creating Buckets and scopes during runtime. When it is ready, user should be able to do operations in that organizations.

Tagging: @simonbasle,@daschl,@Nebasuke

cc:@siju_babu

Thanks
Prince

Hi Prince,

The folks you tagged have all moved on from Couchbase. Let’s get you in touch with some new contacts :slight_smile: @mreiche is now our Spring Data Couchbase expert.

Thanks,
David

1 Like

Our proposed architecture to go for One Bucket per Organization and child organization will be isolated by scope. We re using the Spring Couchbase as data layer> Does it provide capability to dynamically choose database? We will be creating Buckets and scopes during runtime.

There is a hook - in your configuration class that overrides AbstractCouchbaseConfiguration. But it only maps on the entity class - so that won’t work for your case.

@Override
public void configureRepositoryOperationsMapping(RepositoryOperationsMapping baseMapping)

There is no built-in straight forward way to dynamically specify different buckets. I would recommend using scopes for both organizations and sub-organizations (perhaps a scopeName of parentOrg for the parent, and parentOrg_childOrg for the child organization). Scopes can be dynamically selected with both templates and repositories (repositories must extend DynamicProxyable - like this:

public interface UserColRepository extends CouchbaseRepository<UserCol, String>, DynamicProxyable<UserColRepository>

If you really want/need to use buckets - you would need to create and manage the CouchbaseTemplates and Repositories yourself. The commented out code in configureRespositoryOperationsMapping() in this test class shows how to create templates.

I would need to lookup how to dynamically create repositories. Let me know if you need that.

  • Mike
1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.