This is package to deal with common scenarios working with 8base platform
npm install @cobuildlab/8base-utilsThis is a package for functions that are use full in common cases of working with the 8base.com platform.
npm i --save @cobuildlab/8base-utils
| Function | Description |
| ------ | ------ |
| normalize8baseReferenceConnect | Updates an object to change a property with a 8base connect operation. |
| normalize8baseDocumentCreate | Updates an object to change a property with a 8base create operation for a file object. |
| normalize8baseDocumentsCreate | Updates an object to change a property with a 8base create operation for a list of files objects. |
| normalize8baseDocumentDeleteAndUpdate | Updates an object to change a property with a 8base create and/or disconnect operation for a list of files objects. |
| normalize8baseDocumentsDeleteAndUpdate | Updates an object to change a property with a 8base create and/or disconnect operation for a list of files objects. |
- Updates an object to change a property with a 8base connect operation.
- If the value of the key is undefined or null, the property gets deleted from the object.
- This function mutates the data object to reflect the change.
- This function assumes that all 8base IDs are of type string.
Example:
``javascript
import {normalize8baseReferenceConnect} from "@cobuildlab/8base-utils";
const issue = {name :"Issues Name", project: "
normalize8baseReferenceConnect(issue, "project");
console.log(issue);
// {name :"Issues Name", project: {connect:{id: "
`
- Updates an object to change a property with a 8base create operation.
- If the value of the key is undefined or null, the property gets deleted from the object.
- This function mutates the data object to reflect the change.
Example:
`javascript
import {normalize8baseDocumentCreate} from "@cobuildlab/8base-utils";
const issue = {name :"Issues Name", document: {fileId: "
normalize8baseDocumentCreate(issue, "document");
console.log(issue);
// {name :"Issues Name", document: {create:{fileId: "
`
- Updates an object to change a property with a 8base create operation.
- If the value of the key is undefined, null, or an empty array, the property gets deleted from the object.
- This function mutates the data object to reflect the change.
Example:
`javascript
import {normalize8baseDocumentsCreate} from "@cobuildlab/8base-utils";
const issue = {name :"Issues Name", document: [{fileId: "
normalize8baseDocumentsCreate(issue, "document");
console.log(issue);
// {name :"Issues Name", document: {create:[{fileId: "
`
- Helper to update or delete one document key from an Object.
- Updates an object to change a property with a 8base create and/or disconnect operation.
- If the value of the key is undefined, null, or an empty array, the property gets deleted from the object.
- This function mutates the data object to reflect the change.
Example:
`javascript
import {normalize8baseDocumentDeleteAndUpdate} from "@cobuildlab/8base-utils";
const new12 = { a: { fileId: "FILE-ID1", filename:"
const old12 = {};
normalize8baseDocumentDeleteAndUpdate(new12, "a", old12);
expect(new12).toEqual({ a: { create: { fileId: "FILE-ID1", filename:"
`
- Helper to change non null keys to 8base 'delete & create' reference for Documents Lists
- Updates an object to change a property with a 8base create and/or disconnect operation.
- If the value of the key is undefined, null, or an empty array, the property gets deleted from the object.
- This function mutates the data object to reflect the change.
Example:
`javascript
import {normalize8baseDocumentsDeleteAndUpdate} from "@cobuildlab/8base-utils";
const new15 = { a: [{ fileId: "FILE-ID1", filename:"
const old15 = { a: [{ id: "FILE-ID2" }, { id: "ID2" }] };
normalize8baseDocumentsDeleteAndUpdate(new15, "a", old15);
expect(new15).toEqual({ a: { create: [{ fileId: "FILE-ID1", filename:"
``