Reputation: 100
I have many data models. How should I approach when I create my Couchbaselite database? Should create multiple database for every model. Then how should I join them?
Example Object Model:
Restaurant
Waiter
json String: [{ id=..., Name=Rest, adress={id=...,street=..}}]
Upvotes: 0
Views: 44
Reputation: 864
You could use the same database for multiple models, and when you want to join, you could use alias(DataSource.database(db).as("main")
) from same database(below example db
) and join using it.
Below is a swift example,
let q = QueryBuilder
.select(SelectResult.expression(Meta.id.from("main")))
.from(DataSource.database(db).as("main"))
.join(
Join.join(DataSource.database(db).as("secondary"))
.on(Expression.property("prop1").from("main")
.equalTo(Expression.property("prop2").from("secondary"))))
Upvotes: 1