This repository was archived by the owner on Nov 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 46
Issue - Embedded Data Models failing to POST #12
Copy link
Copy link
Open
Description
Hi,
Been using your plugin lately. Faced some issues when I tried to POST a Model that has Embedded Models inside it.
{
"error": {
"name": "ValidationError",
"status": 422,
"message": "The `Option` instance is not valid. Details: `content` is invalid: `updatedAt` can't be blank (value: undefined).",
"statusCode": 422,
"details": {
"context": "Option",
"codes": {
"content": [
"invalid"
]
},
"messages": {
"content": [
"is invalid: `updatedAt` can't be blank"
]
}
},
"stack": "ValidationError: The `Option` instance is not valid. Details: `content` is invalid: `updatedAt` can't be blank (value: undefined).\n at P:\\testproject\\server_workbench\\testproject\\node_modules\\loopback-datasource-juggler\\lib\\dao.js:264:12\n at ModelConstructor.<anonymous> (P:\\testproject\\server_workbench\\testproject\\node_modules\\loopback-datasource-juggler\\lib\\validations.js:472:11)\n at ModelConstructor.next (P:\\testproject\\server_workbench\\testproject\\node_modules\\loopback-datasource-juggler\\lib\\hooks.js:75:12)\n at ModelConstructor.<anonymous> (P:\\testproject\\server_workbench\\testproject\\node_modules\\loopback-datasource-juggler\\lib\\validations.js:469:23)\n at ModelConstructor.trigger (P:\\testproject\\server_workbench\\testproject\\node_modules\\loopback-datasource-juggler\\lib\\hooks.js:65:12)\n at ModelConstructor.Validatable.isValid (P:\\testproject\\server_workbench\\testproject\\node_modules\\loopback-datasource-juggler\\lib\\validations.js:435:8)\n at P:\\testproject\\server_workbench\\testproject\\node_modules\\loopback-datasource-juggler\\lib\\dao.js:260:9\n at P:\\testproject\\server_workbench\\testproject\\node_modules\\loopback-datasource-juggler\\lib\\observer.js:106:23\n at P:\\testproject\\server_workbench\\testproject\\node_modules\\loopback-datasource-juggler\\node_modules\\async\\lib\\async.js:189:25\n at event (P:\\testproject\\server_workbench\\testproject\\node_modules\\loopback-ds-timestamp-mixin\\index.js:29:5)"
}
}Model Info
Option {
id (number, optional),
optionContent (Content, optional),
createdAt (string),
updatedAt (string)
}
Content {
data (string),
type (string),
id (number, optional),
createdAt (string),
updatedAt (string)
}Model's JSON in Loopback:
{
"name": "Option",
"base": "PersistedModel",
"idInjection": true,
"options": {
"validateUpsert": true
},
"properties": {
},
"validations": [],
"relations": {
"content": {
"type": "embedsOne",
"model": "Content",
"property": "optionContent",
"options": {
"validate": true,
"forceId": true,
"persistent": true
}
}
},
"mixins": {
"TimeStamp": true
},
"acls": [],
"methods": []
}
{
"name": "Content",
"base": "PersistedModel",
"idInjection": true,
"options": {
"validateUpsert": true
},
"properties": {
"data": {
"type": "string",
"required": true
},
"type": {
"type": "string",
"required": true
}
},
"mixins": {
"TimeStamp": true
},
"validations": [],
"relations": {},
"acls": [],
"methods": []
}
Here is what I Inserted:
{
"optionContent": {
"data": "asdasd",
"type": "text"
}
}Metadata
Metadata
Assignees
Labels
No labels