Document Design - refrance/sub documents

query
n1ql
stringdocument

#1

Hello All,

I am new to Couchbase. I was read and see videos on web related to

How to design documents
I am confused regarding how I should design my documents for my project. Please help me here and suggest me the best way.
Requirement : Must be fast to update and read.
Here i give small intro of my documents and types.

Type : User
{
_id:767c809b-32af-4010-a56e-a6c075737276,
_type:user,
lastLogin: <Should be reference of login history document>
lastPost: <Should be reference of post document>
likes: [
{<Should be reference of user document>, is_friend:true},
{<Should be reference of user document>,is_firend:false}
]
}

Type : Post
{
_id:08b1deda-dace-9733-036f-6db72a0a7016,
_type:post,
text:“Hello, This is my first post”,
created_date:123456789102,
updated_date:98765412365,
likes_clicked_by: [
<Should be reference of user document>,
<Should be reference of user document>,
]
}

  • I check couchbase odm like ottoman, lounge, etc, They are store {_type:“user”, $ref:“user|767c809b-32af-4010-a56e-a6c075737276”} for populate user when read post info.
  • is it good way?, if yes then how can i write where condition on ref document while populate.
  • is there any other way to save all data at one document? but i also should update in all document reference when i change any info of user document

sorry for long question and poor English.