---
# System prepended metadata

title: Db design for page

---

---
title: Db design for page
---

activity_interactions
[Json schema](http://www.objgen.com/json/models/p7lV)
```json
[
    {
      "_id": "ObjectId()",
      "creator": {
        "user_id": "ObjectId()",
        "user_name": "Sample"
      },
      "date": "2019-08-09T16:23:40.132Z",
      "type": "LIKE|DISLIKE|FOLLOW|SHARE",
      "target": {
        "target_type": "POST|PHOTO",
        "target_id": "ObjectId"
      }
    }
]
```


#### API:

* **GET** /activity/interaction/?type=PAGE_DISLIKE
* **POST** /activity/interaction
* **PUT** /activity/interaction/{id}
* **PATCH** /activity/interaction/{id}
* **DELETE** /activity/interaction/{id}

activity_posts
[Json Chema](http://www.objgen.com/json/models/epH4p)

```json
{
  "_id": "ObjectId()",
  "title": "",
  "content": "",
  "created_date": "2019-08-09T16:17:20.714Z",
  "privacy": "PUBLIC|ONLY_ME|FRIEND",
  "creator": {
    "id": "ObjectId",
    "name": "Sample"
  },
  "object": {
    "id": "ObjectId",
    "name": "Sample",
    "type": "USER|CHANNEL|GROUP"
  },
  "photos": [ "ObjectId()", "ObjectId()" ]
  "stats": {
    "total_like": 2,
    "total_dislike": 3,
    "total_reply": 3,
    "total_share": 2
  }
}
```

activity_comments
[Json Schema](http://www.objgen.com/json/models/fKb)
```json
{
  "_id": "ObjectId",
  "creator": {
    "user_id": "ObjectId",
    "user_name": "sample"
  },
  "content": "mus mauris vitae ultricies leo",
  "created_date": "2019-08-08T08:08:15.833Z",
  "target": {
    "type": "PHOTO|POST",
    "target_id": "ObjectId()"
  },
  "unread_users": [
    "ObjectId(1)",
    "ObjectId(2)",
    "..."
  ]
}
```

* **GET** /comments
* **POST** /comment/
* **PUT** /comment/{id}
* **PATCH** /comment/{id}
* **DELETE** /comment/{id}

activity_comments_replies

[Json schema](http://www.objgen.com/json/models/O9Qo)

```json
{
  "_id": "ObjectId",
  "creator": {
    "user_id": "ObjectId",
    "user_name": "sample"
  },
  "content": "mus mauris vitae ultricies leo",
  "created_date": "2019-08-08T08:11:10.725Z",
  "comment_id": "ObjectId",
  "unread_users": [
    "ObjectId(1)",
    "ObjectId(2)",
    "..."
  ]
}
```

### Activity feed
activity_feed
[Json schema](http://www.objgen.com/json/models/93M)
```json
{
  "_id": "ObjectId",
  "action_type": "LIKE_PAGE|CREATE_POST|UPDATE_POST|DISLIKE_PAGE|UPLOAD_PHOTO...",
  "subject": {
    "id": "ObjectId",
    "type": "USER"
  },
  "object": {
    "id": "ObjectId",
    "type": "USER|PHOTO|GROUP"
  },
  "created_date": "2019-08-09T16:24:17.686Z",
  "privacy": "public",
  "data": {
    "url": "http://gooogle.com",
    "content": "porttitor leo a diam sollicitudin"
  }
}
```
activity_templates
[Json schema](http://www.objgen.com/json/models/jN3ly)

```json
{
  "_id": "ObjectId",
  "action_type": "LIKE_POST|CREATE_POST|UPDATE_POST|DISLIKE_POST|UPLOAD_PHOTO...",
  "template": {
    "en": "${subject} has created ${object}. Visit ${url} for more details.",
    "vi": "${subject} đã tạo ${object}. Vào đây ${url} để biết thêm chi tiết."
  }
}
```



### Photo
photos
[Json schema](http://www.objgen.com/json/models/2h4cF)
```json
{
  "_id": "ObjectId()",
  "path": "path/to/image.png",
  "is_avatar": false,
  "is_cover": false,
  "owner": {
    "owner_id": "ObjectId",
    "type": "USER|CHANNEL|GROUP"
  },
  "like": [
    "ObjectId(1)",
    "ObjectId(2)",
    "ObjectId(3)"
  ],
  "dislike": [
    "ObjectId(1)",
    "ObjectId(2)",
    "ObjectId(3)"
  ],
  "follower": [
    "ObjectId(1)",
    "ObjectId(2)",
    "ObjectId(3)"
  ]
}
```
#### API:

* **GET** /photos?page=&sort=
* **GET** /photo/{photoId}
* **GET** /photo/filter?...&page=&sort=
* **POST** /photos
* **PUT** /photo/{photoId}
* **PATCH** /photo/{photoId}
* **DELETE** /photo/{photoId}


### Group
```json=
{
  "_id": "ObjectId",
  "name": "amet porttitor eget",
  "description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Proin sagittis nisl rhoncus mattis rhoncus urna. Nunc eget lorem dolor sed viverra ipsum.",
  "invites": [
    "ObjectId1",
    "ObjectId2"
  ],
  "members": [
    {
      "_id": "ObjectId",
      "user_id": "ObjectId",
      "allow_notification": false
    },
    {
      "_id": "ObjectId",
      "user_id": "ObjectId",
      "allow_notification": true
    }
  ]
}
```

## Channel page:
Giống như page mà có thêm channel id

## Setting privacy [^1]

[^1]: Phần này discuss lại rồi gắn field privacy vào collection users và channel