Skip to main content

Introduction

info

All examples are provided in two formats: raw JSON body and SDK-like code snippets.

When using the REST API, please ensure that the Content-Type: application/json and authorization token headers are set.

Features


  • Automatic Type Inference: Enjoy seamless type safety with automatic TypeScript inference.
  • Isomorphic Architecture: Fully compatible with both server and browser environments.
  • Zero Dependencies: Lightweight and efficient with no external dependencies.
  • No Configuration Needed: Plug-and-play design requires no setup or configuration.

Installation


NPM:

npm install @collect.so/javascript-sdk

YARN:

yarn add @collect.so/javascript-sdk

PNPM:

pnmp add @collect.so/javascript-sdk

Usage

  1. Get API Token at app.collect.so
  2. Install @collect.so/javascript-sdk
  3. Build something people you want:
import Collect, { CollectModel } from '@collect.so/javascript-sdk';

const CollectInstance = new Collect("API_TOKEN")

// Push any data to Collect the way you perceive it
await CollectInstance.records.createMany({
label: "PRODUCT",
payload: [
{
title: 'T-Shirt',
price: 50,
},
{
title: 'Sneakers',
price: 135,
SIZE: [
{
uk: 8.5,
qty: 5
}
]
}
]
})

// Find it with granular precision and without any query language
await CollectInstance.records.find("PRODUCT", {
where: {
title: { $contains: "Sneakers" },
SIZE: {
uk: { $gte: 8, $lte: 9 },
qty: { $gt: 0 }
}
}
})

Example with data modeling

import Collect, { CollectModel } from '@collect.so/javascript-sdk';

const CollectInstance = new Collect("API_TOKEN")

const UserRepo = new CollectModel(
'USER',
{
name: { type: 'string' },
rating: { type: 'number' },
},
CollectInstance
);

await UserRepo.create({
name: "John Galt",
rating: 100
})

await UserRepo.find({
where: {
rating: { $gte: 50 }
}
})

How this achieved?

Collect achieves its flexibility through a unique hybrid approach to data storage by harnessing the capabilities of Neo4j's graph database, extending beyond its original features. This approach combines the strengths of a strongly typed graph on one hand while offering the flexibility of saving data within the built-in mechanisms of dynamically extending graph structures on the other.

Internal algorithms, including customized BFS (Breadth-First Search) and batching techniques, are intentionally crafted for efficiency and speed. Their primary goal is to provide an outstanding user and developer experience, ensuring smooth and high-speed operations throughout the platform.

In this documentation, you will find comprehensive information on how to use Collect to its fullest potential, from getting started to advanced features.