Skip to content

Replace foreignkey with embedded object rather than having both. #1646

@drizzle042

Description

@drizzle042

This would save the extra bytes of memory required to keep both keys. Since embedded object's id is equivalent to foreignkey, we can do away with the foreignkey and save those extra bytes.

Current behaviour:

Before _embed:

{
  "employees": [
    { "id": 0, "name": "Tim", "lastName": "S", "role": "developer" }
  ],
  "feedbacks": [
    { "id": 0, "employeeId": 0, "text": "Great dev"}
  ]
}

After _embed:

[
  {
    "id": 0,
    "employeeId": 0,
    "text": "Great dev",
    "employee": {
      "id": 0,
      "name": "Tim",
      "lastName": "S",
      "role": "developer"
    }
  }
]

Expected behaviour:

Before _embed:

{
  "employees": [
    { "id": 0, "name": "Tim", "lastName": "S", "role": "developer" }
  ],
  "feedbacks": [
    { "id": 0, "employeeId": 0, "text": "Great dev"}
  ]
}

After _embed:

[
  {
    "id": 0,
    "text": "Great dev",
    "employee": {
      "id": 0,
      "name": "Tim",
      "lastName": "S",
      "role": "developer"
    }
  }
]

Might not seem like much but it will really save a lot in network data transfer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions