Hi,
we are working with CBL 2.0 .NET and seemingly I can’t figure out how to correctly use Joins in Queries.
Consider a database with two simple documents:
{
"_id": "author_1",
"name": "John Doe"
}
–
{
"_id": "blog_post_1",
"title": "Lorem Ipsum",
"author": "author_1"
}
Since the documentation for Joins is not up yet, I tried to fiddle around and thought the following code should work (db
being a reference to the CBL-Database):
var query = Query.Select(SelectResult.All())
.From(DataSource.Database(db))
.Joins(
Join.InnerJoin(DataSource.Database(db)).On(
Expression.Meta().ID.EqualTo(Expression.Property("author"))
)
);
IResultSet rows = query.Run();
But running that Query never finishes. It also throws no exception or such, so I don’t really know what I’m doing wrong. I also tried a couple of other things, like switching the “JoinOn”-Expression the other way around as well as joining on properties instead of meta-data. But the query always just never finishes.
So I hope someone could give me a pointer on what the correct API-Usage would be :).
As a side-question I would also ask if this is “the way to go”. NoSQL is still kind of new to us.
In reality we are talking about ~1-5 million documents of various “types” (i.e.: each “type” being akin to a SQL-Table and each document representing something akin to a SQL-Row-Entry and we put all documents from all tables into 1 bucket). Would you use N1QL-Joins like above in such a scenario or would it be faster/better to use GetDocument(authorId)
instead? Or even use views instead?
Thanks & best regards,
Lars