@collect.so/javascript-sdk
TypeScript icon, indicating that this package has built-in type declarations

0.24.3 • Public • Published

Collect Logo

Collect SDK

The Collect.so SDK for JavaScript and TypeScript

NPM Version License

NPM Downloads npm bundle size

Made with Node Package - Typescript

HomepageBlogPlatformDocsExamples

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. Obtain Collect API Token: Grab your API token from the Dashboard.
  2. Setup Collect Instance: Initialize your Collect instance with obtained token.
  3. (Optional) Define Data Models: Tailor your data models to fit your needs.
  4. Manage Your Data: Push, link, fetch, and manage your data effortlessly.

TLDR;

/* ./your-app/src/collect.ts */

import CollectSDK, { CollectModel } from '@collect.so/sdk'

// Setup Collect instance
const Collect = new CollectSDK("API_TOKEN")

// Optionaly define Model
export const UserRepo = new CollectModel(
    'USER',
    {
        name: { type: 'string' },
        email: { type: 'string', uniq: true },
        verified: { type: 'boolean', default: false },
        hobbies: { type: 'string', multiple: true, requiered: false },
        rating: { type: 'number', default: 1 },
        created: { type: 'datetime', default: () => new Date().toISOString() },
        password: { type: 'string' }
    },
    Collect
)

// Create new Record
const newUser = await UserRepo.create({
    name: "John Galt",
    email: 'john.g@example.com',
    hobbies: ['Programming', 'Hiking'],
    password: '********'
})

// Find Records by specific criteria
const matchedUsers = await UserRepo.find({
    where: {
        email: { $ne: 'john.g@example.com' },
        hobbies: { $in: ['Hiking'] },
        rating: { $gte: 1.5 }
    }
})
You're Awesome! 🚀

Check the Docs and Examples Repository to learn more 🤓

Contributing


See CONTRIBUTING.md.

Readme

Keywords

none

Package Sidebar

Install

npm i @collect.so/javascript-sdk

Weekly Downloads

3

Version

0.24.3

License

MIT

Unpacked Size

219 kB

Total Files

101

Last publish

Collaborators

  • kumomix
  • 1px.one