deep-foundation / deep-foundation/deeplinks
Unable to Insert a Link with number: 0 Using plv8 Sync Handler
- Dominant language
- TypeScript
- Stars
- 13
- Forks
- 8
- PR merge metrics
- No merged PRs in 30d
Description
### Describe the bug
When trying to insert a link using the plv8 sync handler with a value of number: 0, the value is not added and remains null. However, inserting a link with a number: 1 works as expected.
### Expected Behavior
When inserting a link using the plv8 sync handler with a value of number: 0, the value should be successfully added as 0 and not default to null.
Specifically, for the given code:
```js
({ data, deep, require }) => {
const newLinkId = data["newLink"]["id"];
const accountBalanceTypeId = deep.id('@trooper2003/account-ui', 'AccountBalance')
deep.insert({
type_id: accountBalanceTypeId,
from_id: newLinkId,
to_id: newLinkId,
number: 0
})
}
```
The expected result should be:
```js
from_id: 1502
id: 1503
to_id: 1502
type_id: 1091
value:
id: SOME_ID
link_id: 1503
value: 0
__typename: "links"
```
### Current Behavior
Example 1: Inserting with number: 0
```js
({ data, deep, require }) => {
const newLinkId = data["newLink"]["id"];
const accountBalanceTypeId = deep.id('@trooper2003/account-ui', 'AccountBalance')
deep.insert({
type_id: accountBalanceTypeId,
from_id: newLinkId,
to_id: newLinkId,
number: 0
})
}
```
Result:
```js
from_id: 1502
id: 1503
to_id: 1502
type_id: 1091
value: null
__typename: "links"
```
Example 2: Inserting with number: 1
```js
({ data, deep, require }) => {
const newLinkId = data["newLink"]["id"];
const accountBalanceTypeId = deep.id('@trooper2003/account-ui', 'AccountBalance')
deep.insert({
type_id: accountBalanceTypeId,
from_id: newLinkId,
to_id: newLinkId,
number: 1
})
}
```
Result:
```js
from_id: 1513
id: 1514
to_id: 1513
type_id: 1091
value:
id: 7
link_id: 1514
value: 1
```
### Steps to reproduce
Minimal Reproducible Example:
```js
({ data, deep }) => {
deep.insert({
type_id: 1,
number: 0
})
}
```
### Environment
_No response_
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.