deep-foundation / deep-foundation/deeplinks
Unable to add value to a newly created link using a synchronous (plv8) handler
- Dominant language
- TypeScript
- Stars
- 13
- Forks
- 8
- PR merge metrics
- No merged PRs in 30d
Description
### Describe the bug
When attempting to add a value to a newly created link via a synchronous plv8 handler, the operation fails. The expected behavior is for the value to be inserted without any issues, but this does not occur.
### Expected Behavior
When a new link of type rubAccount is created, it should automatically have a value inserted into it, matching the value of the rubAccount type.
### Current Behavior
The link is not being inserted.
Error Message:
```js
Uncaught (in promise) Error: DeepClient Insert Error: Not-NULL violation. null value in column "type_id" violates not-null constraint
at R. (3122-d0bb67c6681de981.js:104:16195)
at Generator.throw ()
at a (3122-d0bb67c6681de981.js:104:6894)
```
Code Snippet:
```js
({ data, deep}) => {
const {newLink} = data;
const {data: [typeLink]} = deep.select({id: newLink.type_id});
const newValue = typeLink?.value?.value;
deep.insert(
{
link_id: newLink.id, value: newValue
},
{
table: `${typeof newValue}s`
}
);
}
```
another code snippet:
```js
({ data, deep}) => {
const {newLink} = data;
const {data: [typeLink]} = deep.select({id: newLink.type_id})
const newValue = typeLink?.value?.value
deep.insert({
number: {
data: {
link_id: newLink.id, value: newValue
}
}
});
}
```
### Steps to reproduce
Minimal Reproducible Example:
```js
({ data, deep}) => {
const {newLink} = data;
deep.insert({
object: {
data: {
link_id: newLink.id, value: 1
}
}
});
}
```
or:
```js
({ data, deep}) => {
const {newLink} = data;
deep.insert(
{
link_id: newLink.id, value: 1
},
{
table: numbers
}
);
}
```
### Environment
_No response_
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.