Skip to main content

NoSQL Database Documentation

Service: Brok

Database Connection

  • Database Type: MongoDB
  • ORM: Mongoose
  • Dataname: prima-vod

Collection: contents

FieldTypeRequiredDefaultUniqueDescription
content_idStringYes-YesUnique identifier for content
priceNumberNo-NoProperty price
unit_priceStringNo-NoPrice unit (VND, USD, etc.)
areaNumberNo-NoProperty area
unit_areaStringNo-NoArea unit (m2, sqft, etc.)
hash_tagsArray[String]No-NoTags associated with content
geoGeoJSONNo-NoGeographic coordinates (Point with [longitude, latitude])
boostObjectNo-NoContent boost settings
profit_rateObjectNo{roi: 80, roa: 60}NoProfit rate calculations (ROI and ROA)
amenitiesArray[String]No-NoProperty amenities list
videoObjectNo-NoVideo metadata (URL, resolution, duration, status, social platforms)
content_typeStringYes-NoMIME type (video/mp4, image/jpeg, etc.)
real_estate_infoObjectYes-NoLegal certificates, apartment type, project status
content_infoArray[Object]No-NoMultilingual content (lang, project_name, description, address, location)
imagesArray[Object]No-NoImage gallery with ID, URL, and name
uploaderObjectNo-NoUser who uploaded content (user_id, phone, name, avatar)
createdAtDateAutoDate.nowNoCreation timestamp
updatedAtDateAutoDate.nowNoLast update timestamp

Relations: References user data through uploader.user_id

Indexes:

  • Text index on content_info.project_name
  • 2dsphere index on geo field

Collection: contentreactions

FieldTypeRequiredDefaultUniqueDescription
content_idStringYes-NoReference to content
user_idStringYes-NoUser who reacted
reaction_typeStringYes-NoType of reaction (like, love, haha, wow, sad, angry)
createdAtDateAutoDate.nowNoCreation timestamp
updatedAtDateAutoDate.nowNoLast update timestamp

Relations: References contents collection via content_id, references users via user_id

Indexes: Compound unique index on (content_id, user_id)


Collection: masterdata

FieldTypeRequiredDefaultUniqueDescription
keyStringYes-YesUnique identifier for master data type
nameStringYes-NoDisplay name of the master data
valuesArray[Object]No[]NoArray of value-label pairs for different languages
createdAtDateAutoDate.nowNoCreation timestamp
updatedAtDateAutoDate.nowNoLast update timestamp

Relations: No direct relations, used as lookup data

Note: Values contain {value: string, label: Map<string, string>} for multilingual support


Collection: oauthtokens

FieldTypeRequiredDefaultUniqueDescription
userIdStringYes-NoUser identifier
platformStringYes-NoOAuth platform (YOUTUBE, TIKTOK)
accessTokenStringYes-NoOAuth access token
refreshTokenStringNo-NoOAuth refresh token
expiresAtDateNo-NoToken expiration time
scopeStringNo-NoOAuth scope permissions
platformUserIdStringNo-NoUser ID on the platform
platformUsernameStringNo-NoUsername on the platform
createdAtDateAutoDate.nowNoCreation timestamp
updatedAtDateAutoDate.nowNoLast update timestamp

Relations: References users via userId


Collection: overview

FieldTypeRequiredDefaultUniqueDescription
_idStringYes-YesCustom identifier
titleStringYes-NoOverview title
contentObjectYes-NoMultilingual content (vi, en, ko)
createdAtDateAutoDate.nowNoCreation timestamp
updatedAtDateAutoDate.nowNoLast update timestamp

Relations: No direct relations, stores static content

Service: global-store


Collection: users (prima-global-store & prima-sns)

FieldTypeRequiredDefaultUniqueDescription
_idStringYes-YesCustom user identifier
usernameStringYes-NoUser's username
emailStringYes-NoUser's email address
email_verifiedBooleanNofalseNoEmail verification status
phone_numberStringNo-NoUser's phone number
phone_number_verifiedBooleanNofalseNoPhone verification status
nameStringNo-NoFull name
family_nameStringNo-NoLast name
given_nameStringNo-NoFirst name
pictureStringNo-NoProfile picture URL
roleStringNo-NoUser role
deleted_atDateNonullNoSoft delete timestamp
createdAtDateAutoDate.nowNoCreation timestamp
updatedAtDateAutoDate.nowNoLast update timestamp

Relations: Referenced by many collections (contents.uploader, oauth tokens, etc.)

Indexes:

  • Index on username
  • Index on deleted_at

Collection: call_center

FieldTypeRequiredDefaultUniqueDescription
roomIdStringYes-NoCall room identifier
senderIdStringYes-NoCaller user ID
receiverIdStringYes-NoReceiver user ID
startedAtDateYes-NoCall start time
endedAtDateNo-NoCall end time
statusStringYes-NoCall status (initiated, answered, ended, missed)
createdAtDateAutoDate.nowNoCreation timestamp
updatedAtDateAutoDate.nowNoLast update timestamp

Relations: References users via senderId and receiverId


Collection: chat_messages

FieldTypeRequiredDefaultUniqueDescription
roomIdObjectIdYes-NoReference to chat room
senderObjectYes-NoMessage sender (userId, name, picture)
msgStringNo-NoMessage text content
attachmentsArray[Object]No-NoFile attachments (type, fileName, fileSize, url, downloadable)
reactionsArray[Object]No-NoMessage reactions (author, emoji)
hiddenBooleanNofalseNoMessage visibility
editedAtDateNo-NoLast edit timestamp
deletedAtDateNo-NoSoft delete timestamp
createdAtDateAutoDate.nowNoCreation timestamp
updatedAtDateAutoDate.nowNoLast update timestamp

Relations: References chat_rooms via roomId

Indexes: Index on roomId


Collection: chat_rooms

FieldTypeRequiredDefaultUniqueDescription
participantsArray[String]Yes-NoArray of user IDs in the room
typeStringNo'direct'NoRoom type (direct, group)
lastMessageObjectIdNo-NoReference to last message
ownerObjectNo-NoRoom owner (userId, name, picture)
createdAtDateAutoDate.nowNoCreation timestamp
updatedAtDateAutoDate.nowNoLast update timestamp

Relations: References chat_messages via lastMessage, references users via participants

Indexes: Index on participants


Collection: chat_subscriptions

FieldTypeRequiredDefaultUniqueDescription
userIdStringYes-NoSubscriber user ID
roomIdObjectIdYes-NoReference to chat room
lastSeenDateNoDate.nowNoLast seen timestamp
nameStringYes-NoDisplay name
fnameStringNo-NoFull name
pictureStringNo-NoProfile picture URL
unreadNumberNo0NoUnread message count
alertBooleanNotrueNoAlert notification setting
participantsArray[Object]No-NoRoom participants info

Relations: References chat_rooms via roomId, references users via userId

Indexes: Compound unique index on (userId, roomId, name, fname)


Collection: comments

FieldTypeRequiredDefaultUniqueDescription
contentIdStringYes-NoReference to content
authorObjectYes-NoComment author (userId, name, avatarUrl)
msgStringYes-NoComment message
parentIdObjectIdNo-NoParent comment for replies
reactionsArray[Object]No-NoComment reactions (author, emoji)
deletedAtDateNonullNoSoft delete timestamp
createdAtDateAutoDate.nowNoCreation timestamp
updatedAtDateAutoDate.nowNoLast update timestamp

Relations: References contents via contentId, self-reference via parentId for reply threads

Indexes:

  • Index on contentId
  • Index on parentId
  • Index on deletedAt

Collection: events

FieldTypeRequiredDefaultUniqueDescription
event_idStringYes-NoUnique event identifier
event_typeStringYes-NoType of event being tracked
messageStringNo-NoEvent description message
user_idStringYes-NoUser who triggered the event
event_dataMixedYes-NoAdditional event data
deviceObjectYes-NoDevice information (ip, user_agent)
source_serviceStringYes-NoService that generated the event
createdAtDateAutoDate.nowNoCreation timestamp
updatedAtDateAutoDate.nowNoLast update timestamp

Relations: References users via user_id

Indexes:

  • Index on event_id
  • Index on event_type
  • Index on message
  • Index on user_id

Collection: roles

FieldTypeRequiredDefaultUniqueDescription
_idObjectIdAutoObjectId()YesMongoDB ObjectId
nameStringYes-YesRole name (admin, broker, guest, end_user, etc.)
descriptionStringYes-NoRole description
permission_idsArray[String]No[]NoArray of permission ObjectIds
permission_namesArray[String]No[]NoCached permission names for performance
is_activeBooleanNotrueNoRole activation status
created_atDateAutoDate.nowNoCreation timestamp
updated_atDateAutoDate.nowNoLast update timestamp

Relations: References permissions collection via permission_ids

Indexes:

  • Unique index on name

Note: System includes predefined roles: admin, admin_readonly, guest, end_user, broker, sale, prop, owner


Collection: permissions

FieldTypeRequiredDefaultUniqueDescription
_idObjectIdAutoObjectId()YesMongoDB ObjectId
nameStringYes-YesPermission name (create:user, read:content, etc.)
descriptionStringYes-NoPermission description
is_activeBooleanNotrueNoPermission activation status
created_atDateAutoDate.nowNoCreation timestamp
updated_atDateAutoDate.nowNoLast update timestamp

Relations: Referenced by roles collection via permission_ids

Indexes:

  • Unique index on name

Note: Permissions follow pattern action:resource (e.g., create:user, read:content, delete_role:root)