@DBRef equivalent

Hello,

I am migrating a web project from Mongo to Couchbase. Most changes are already done, but there is something that I really don’t know how to replicate.

I have this:
@DBRef
private List productConfiguration;

The @DBRef makes reference another document (it is explained here https://docs.mongodb.com/manual/reference/database-references/ ), and I really can’t find an equivalent to that. I was thinking about using @Autowired, but I think that the behavior is not the same.

Does anybody know what can I replace it with?

Hi Ana,

I’m not an expert, but I suspect a N1QL join might approximate what @DBRef was doing.

Thanks,
David

This had been looked at once before when someone else requested similar functionality. From my recollection…

@DBRef is implemented on the client (or “driver”). It wasn’t in all clients, but just a few. The @DBRef would transparently turn it unto CRUD operations on behalf of the application. Basically, inserting a document into another document from it’s ID reference.

When we looked at it, there were really a couple of broad areas of use cases. One, the database JOIN, that @david.nault points out. Couchbase has a more general solution to that. Two, simple embedding, sort of object graph like. We felt this was already do-able with a small bit of app logic and that any error conditions or adjustment to logic were better done at the app level rather than trying to do it for the app. There was a bit too much magic if something went wrong or if the document changed.

Also, even then, we noted that @DBRef was deprecated and it’s use discouraged.

Let us know if there’s something you’re trying to work out how to approach with Couchbase @anaesther-- we can probably guide you on top of our programming model.