NoSQL Database Documentation
Service: Brok
Database Connection
- Database Type: MongoDB
- ORM: Mongoose
- Dataname: prima-vod
Collection: contents
| Field | Type | Required | Default | Unique | Description |
|---|---|---|---|---|---|
| content_id | String | Yes | - | Yes | Unique identifier for content |
| price | Number | No | - | No | Property price |
| unit_price | String | No | - | No | Price unit (VND, USD, etc.) |
| area | Number | No | - | No | Property area |
| unit_area | String | No | - | No | Area unit (m2, sqft, etc.) |
| hash_tags | Array[String] | No | - | No | Tags associated with content |
| geo | GeoJSON | No | - | No | Geographic coordinates (Point with [longitude, latitude]) |
| boost | Object | No | - | No | Content boost settings |
| profit_rate | Object | No | {roi: 80, roa: 60} | No | Profit rate calculations (ROI and ROA) |
| amenities | Array[String] | No | - | No | Property amenities list |
| video | Object | No | - | No | Video metadata (URL, resolution, duration, status, social platforms) |
| content_type | String | Yes | - | No | MIME type (video/mp4, image/jpeg, etc.) |
| real_estate_info | Object | Yes | - | No | Legal certificates, apartment type, project status |
| content_info | Array[Object] | No | - | No | Multilingual content (lang, project_name, description, address, location) |
| images | Array[Object] | No | - | No | Image gallery with ID, URL, and name |
| uploader | Object | No | - | No | User who uploaded content (user_id, phone, name, avatar) |
| createdAt | Date | Auto | Date.now | No | Creation timestamp |
| updatedAt | Date | Auto | Date.now | No | Last 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
| Field | Type | Required | Default | Unique | Description |
|---|---|---|---|---|---|
| content_id | String | Yes | - | No | Reference to content |
| user_id | String | Yes | - | No | User who reacted |
| reaction_type | String | Yes | - | No | Type of reaction (like, love, haha, wow, sad, angry) |
| createdAt | Date | Auto | Date.now | No | Creation timestamp |
| updatedAt | Date | Auto | Date.now | No | Last 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
| Field | Type | Required | Default | Unique | Description |
|---|---|---|---|---|---|
| key | String | Yes | - | Yes | Unique identifier for master data type |
| name | String | Yes | - | No | Display name of the master data |
| values | Array[Object] | No | [] | No | Array of value-label pairs for different languages |
| createdAt | Date | Auto | Date.now | No | Creation timestamp |
| updatedAt | Date | Auto | Date.now | No | Last update timestamp |
Relations: No direct relations, used as lookup data
Note: Values contain {value: string, label: Map<string, string>} for multilingual support
Collection: oauthtokens
| Field | Type | Required | Default | Unique | Description |
|---|---|---|---|---|---|
| userId | String | Yes | - | No | User identifier |
| platform | String | Yes | - | No | OAuth platform (YOUTUBE, TIKTOK) |
| accessToken | String | Yes | - | No | OAuth access token |
| refreshToken | String | No | - | No | OAuth refresh token |
| expiresAt | Date | No | - | No | Token expiration time |
| scope | String | No | - | No | OAuth scope permissions |
| platformUserId | String | No | - | No | User ID on the platform |
| platformUsername | String | No | - | No | Username on the platform |
| createdAt | Date | Auto | Date.now | No | Creation timestamp |
| updatedAt | Date | Auto | Date.now | No | Last update timestamp |
Relations: References users via userId
Collection: overview
| Field | Type | Required | Default | Unique | Description |
|---|---|---|---|---|---|
| _id | String | Yes | - | Yes | Custom identifier |
| title | String | Yes | - | No | Overview title |
| content | Object | Yes | - | No | Multilingual content (vi, en, ko) |
| createdAt | Date | Auto | Date.now | No | Creation timestamp |
| updatedAt | Date | Auto | Date.now | No | Last update timestamp |
Relations: No direct relations, stores static content
Service: global-store
Collection: users (prima-global-store & prima-sns)
| Field | Type | Required | Default | Unique | Description |
|---|---|---|---|---|---|
| _id | String | Yes | - | Yes | Custom user identifier |
| username | String | Yes | - | No | User's username |
| String | Yes | - | No | User's email address | |
| email_verified | Boolean | No | false | No | Email verification status |
| phone_number | String | No | - | No | User's phone number |
| phone_number_verified | Boolean | No | false | No | Phone verification status |
| name | String | No | - | No | Full name |
| family_name | String | No | - | No | Last name |
| given_name | String | No | - | No | First name |
| picture | String | No | - | No | Profile picture URL |
| role | String | No | - | No | User role |
| deleted_at | Date | No | null | No | Soft delete timestamp |
| createdAt | Date | Auto | Date.now | No | Creation timestamp |
| updatedAt | Date | Auto | Date.now | No | Last update timestamp |
Relations: Referenced by many collections (contents.uploader, oauth tokens, etc.)
Indexes:
- Index on username
- Index on deleted_at
Collection: call_center
| Field | Type | Required | Default | Unique | Description |
|---|---|---|---|---|---|
| roomId | String | Yes | - | No | Call room identifier |
| senderId | String | Yes | - | No | Caller user ID |
| receiverId | String | Yes | - | No | Receiver user ID |
| startedAt | Date | Yes | - | No | Call start time |
| endedAt | Date | No | - | No | Call end time |
| status | String | Yes | - | No | Call status (initiated, answered, ended, missed) |
| createdAt | Date | Auto | Date.now | No | Creation timestamp |
| updatedAt | Date | Auto | Date.now | No | Last update timestamp |
Relations: References users via senderId and receiverId
Collection: chat_messages
| Field | Type | Required | Default | Unique | Description |
|---|---|---|---|---|---|
| roomId | ObjectId | Yes | - | No | Reference to chat room |
| sender | Object | Yes | - | No | Message sender (userId, name, picture) |
| msg | String | No | - | No | Message text content |
| attachments | Array[Object] | No | - | No | File attachments (type, fileName, fileSize, url, downloadable) |
| reactions | Array[Object] | No | - | No | Message reactions (author, emoji) |
| hidden | Boolean | No | false | No | Message visibility |
| editedAt | Date | No | - | No | Last edit timestamp |
| deletedAt | Date | No | - | No | Soft delete timestamp |
| createdAt | Date | Auto | Date.now | No | Creation timestamp |
| updatedAt | Date | Auto | Date.now | No | Last update timestamp |
Relations: References chat_rooms via roomId
Indexes: Index on roomId
Collection: chat_rooms
| Field | Type | Required | Default | Unique | Description |
|---|---|---|---|---|---|
| participants | Array[String] | Yes | - | No | Array of user IDs in the room |
| type | String | No | 'direct' | No | Room type (direct, group) |
| lastMessage | ObjectId | No | - | No | Reference to last message |
| owner | Object | No | - | No | Room owner (userId, name, picture) |
| createdAt | Date | Auto | Date.now | No | Creation timestamp |
| updatedAt | Date | Auto | Date.now | No | Last update timestamp |
Relations: References chat_messages via lastMessage, references users via participants
Indexes: Index on participants
Collection: chat_subscriptions
| Field | Type | Required | Default | Unique | Description |
|---|---|---|---|---|---|
| userId | String | Yes | - | No | Subscriber user ID |
| roomId | ObjectId | Yes | - | No | Reference to chat room |
| lastSeen | Date | No | Date.now | No | Last seen timestamp |
| name | String | Yes | - | No | Display name |
| fname | String | No | - | No | Full name |
| picture | String | No | - | No | Profile picture URL |
| unread | Number | No | 0 | No | Unread message count |
| alert | Boolean | No | true | No | Alert notification setting |
| participants | Array[Object] | No | - | No | Room participants info |
Relations: References chat_rooms via roomId, references users via userId
Indexes: Compound unique index on (userId, roomId, name, fname)
Collection: comments
| Field | Type | Required | Default | Unique | Description |
|---|---|---|---|---|---|
| contentId | String | Yes | - | No | Reference to content |
| author | Object | Yes | - | No | Comment author (userId, name, avatarUrl) |
| msg | String | Yes | - | No | Comment message |
| parentId | ObjectId | No | - | No | Parent comment for replies |
| reactions | Array[Object] | No | - | No | Comment reactions (author, emoji) |
| deletedAt | Date | No | null | No | Soft delete timestamp |
| createdAt | Date | Auto | Date.now | No | Creation timestamp |
| updatedAt | Date | Auto | Date.now | No | Last 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
| Field | Type | Required | Default | Unique | Description |
|---|---|---|---|---|---|
| event_id | String | Yes | - | No | Unique event identifier |
| event_type | String | Yes | - | No | Type of event being tracked |
| message | String | No | - | No | Event description message |
| user_id | String | Yes | - | No | User who triggered the event |
| event_data | Mixed | Yes | - | No | Additional event data |
| device | Object | Yes | - | No | Device information (ip, user_agent) |
| source_service | String | Yes | - | No | Service that generated the event |
| createdAt | Date | Auto | Date.now | No | Creation timestamp |
| updatedAt | Date | Auto | Date.now | No | Last 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
| Field | Type | Required | Default | Unique | Description |
|---|---|---|---|---|---|
| _id | ObjectId | Auto | ObjectId() | Yes | MongoDB ObjectId |
| name | String | Yes | - | Yes | Role name (admin, broker, guest, end_user, etc.) |
| description | String | Yes | - | No | Role description |
| permission_ids | Array[String] | No | [] | No | Array of permission ObjectIds |
| permission_names | Array[String] | No | [] | No | Cached permission names for performance |
| is_active | Boolean | No | true | No | Role activation status |
| created_at | Date | Auto | Date.now | No | Creation timestamp |
| updated_at | Date | Auto | Date.now | No | Last 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
| Field | Type | Required | Default | Unique | Description |
|---|---|---|---|---|---|
| _id | ObjectId | Auto | ObjectId() | Yes | MongoDB ObjectId |
| name | String | Yes | - | Yes | Permission name (create:user, read:content, etc.) |
| description | String | Yes | - | No | Permission description |
| is_active | Boolean | No | true | No | Permission activation status |
| created_at | Date | Auto | Date.now | No | Creation timestamp |
| updated_at | Date | Auto | Date.now | No | Last 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)