Unfortunately i couldn’t find any Java driver Async examples.It would be useful if any of you can give some pointers.
Hi Krishna,
You can find async tutorials at MongoDB Java Async Driver, especially for aggregation see async aggregation framework .
For $lookup operator example you can execute code as below:
collection.aggregate(Arrays.asList(
Aggregates.lookup("fromCollection", "localField", "foreignField", "asOutputArrayField")
)).forEach(printBlock, callbackWhenFinished);
See more information on Aggregation Lookup Builders.
Another great async code example are the tour example files. Also, as the nature of async is non-blocking, you may find the use of CountDownLatch useful for ‘await’ operations.
I am using two collections because we need to have getAllDocuments from both the collection and there will be write operations in both these collection. So i don’t want to use the embed option
Document modelling depends on your use case, as long as the model benefits your application usage of the data and the inherent structure of the data. You may find Data Model Examples and Patterns a good resource, it covers different types of relationships.
Regards,
Wan.