0.24.3 • Published 10 months ago

@collect.so/javascript-sdk v0.24.3

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

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 }
    }
})

Check the Docs and Examples Repository to learn more 🤓

Contributing


See CONTRIBUTING.md.

0.24.3

10 months ago

0.24.2

10 months ago

0.24.1

10 months ago

0.20.0

1 year ago

0.23.0

12 months ago

0.21.0

1 year ago

0.24.0

12 months ago

0.22.0

1 year ago

0.19.0

1 year ago

0.18.0

1 year ago

0.16.0

1 year ago

0.17.0

1 year ago

0.13.0

1 year ago

0.14.0

1 year ago

0.15.0

1 year ago

0.12.0

1 year ago

0.11.0

1 year ago

0.10.0

1 year ago

0.9.0

1 year ago

0.8.0

1 year ago

0.7.0

1 year ago

0.6.0

1 year ago

0.5.0

1 year ago

0.4.0

1 year ago

0.3.0

1 year ago

0.2.0

1 year ago

0.1.0

1 year ago

0.0.2

2 years ago

0.0.1

2 years ago

0.0.0

2 years ago