Socket
Socket
Sign inDemoInstall

@tableland/jeti

Package Overview
Dependencies
462
Maintainers
5
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @tableland/jeti

A TypeScript/JavaScript extension for the @tableland/sdk for inserting and retreiving IPFS content from tables


Version published
Weekly downloads
84
increased by7.69%
Maintainers
5
Created
Weekly downloads
 

Readme

Source

@tableland/jeti (JavaScript Extension for Tableland Integrations)

Lint and test GitHub package.json version Release standard-readme compliant

A TypeScript/JavaScript library for inserting and extracting IPFS data to and from Tableland queries using the @tableland/sdk.

Table of Contents

Background

The Tableland project provides a zero-config Typescript/Javascript SDK that make it easy to interact with the Tableland network from Ethereum-based applications. The @tableland/jeti SDK builds on that, allow you to easily add IPFS data to tableland, and read the data from tableland.

Simply import the library, connect to the Tableland network, and you are ready to start creating and updating tables.

Install

Installation is easy using npm or yarn. An ES bundle is also available for those operating purely in a browser environment.

npm i @tableland/jeti

Note: Not seeing the build type you need for your project or idea? Let us know, we're happy to work with you to improve the SDK usability!

Usage

Pin to IPFS

In this example, using pinToLocal as a tagged template will insert the proper values in your statement, while simultaneously uploading files to your remote pinning services.

Using the resolve function of pinToLocal fetches the data from IPFS into the result set.

import { Database } from "@tableland/sdk";

// For pinning to a local IPFS node
import { pinToLocal, skip } from "@tableland/jeti";

const db = new Database();

const query = await pinToLocal`INSERT INTO MyTable_31337_1 (id, file) values (1, '${file}');`
// Result: INSERT INTO MyTable_31337_1 (id, file) values (id, 'ipfs://bafy...etc');
// The pinToLocal also pinned the file to your local IPFS node.

db.prepare(query).all();

// 1 block time later.

const resultSet = await db.prepare("SELECT * FROM MyTable_31337_1;").all();

// Only attempts to fetch 'file' column from IPFS
const { rows, columns } = await pinToLocal.resolve(resultSet, ["file"]);

Create your own

import { createProcessor } from '@tableland/jeti';

import { createProcessor } from "@tableland/jeti";
import { ipfsPin, ipfsFetch } from "some-custom-ipfs-lib";

const ipfs = createProcessor(ipfsPin, ipfsFetch);

const db = new Database();

const message = getFile();
const image = getImage();
const query = await ipfs`
INSERT
  INTO MyTable_31337_1
    (id, message, image)
    values
    (
      0,
      '${message}',
      '${image}'
    )`;

This would use your implementations of the asynchronous functions which are used in the template. The functions can have side effects. The only rule is they might ultimately return a string.

More uses

More uses can be found in our docs

Feedback

Reach out with feedback and ideas:

Maintainers

@awmuncy

Contributing

PRs accepted.

To get started clone this repo, then do:

# use the latest node and npm LTS
npm install
npm run build

# see if everything is working
npm test

Small note: If editing the README, please conform to the standard-readme specification.

License

MIT AND Apache-2.0, © 2021-2022 Tableland Network Contributors

Keywords

FAQs

Last updated on 30 May 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc