Skip to content

EmbedsMany relation assigns default value to relation objects in response #2882

@SowmyaGrama

Description

@SowmyaGrama

I have 2 model Task and Hearts, Task embedsMany hearts.
task.json

{
  "name": "Task",
  "base": "PersistedModel",
  "idInjection": true,
  "options": {
    "validateUpsert": true
  },
  "properties": {
    "taskId": {
      "type": "string"
    }
  },
  "validations": [],
  "relations": {
    "hearts": {
      "type": "embedsMany",
      "model": "hearts",
      "property": "heartsList",
      "options": {
        "validate": false,
        "forceId": false
      }
    }
    }},
  "acls": [],
  "methods": {}
}

hearts.json

{
  "name": "hearts",
  "base": "PersistedModel",
  "idInjection": true,
  "options": {
    "validateUpsert": true
  },
  "properties": {
    "hid": {
      "type": "string"
    }
  },
  "validations": [],
  "relations": {

  },
  "acls": [],
  "methods": {}
}

After model creation when i do a POST call.
Request:
POST http://localhost:3000/api/Tasks
Payload:
{
"taskId": "string"
}
Response:
{
"taskId": "string",
"id": 1,
"heartsList": []
}

Expected Result: Since I did not pass heartsList I do not expect it to be added in response, We have a situation where the heartsList property is readonly and should not be passed for POST Call.

Is there a way to omit it from getting added with default empty brackets?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions