clay-base-sdk
v0.0.66
Published
Clay base SDK
Downloads
21
Readme
Clay Base SDK
What is Clay Base? Clay Base is the serverless stateless database. Ideal for Lambda functions. Learn more
This SDK connects to Clay Base seemlessly using your Private key.
Install
Using npm
:
npm install clay-base-sdk
Usage
Inserting rows:
const Base = require('clay-base-sdk')
Base.initialize('PRIVATE_KEY') // private key
Base.users.insert({
username: 'playerunkown',
game: 'battlegrounds'
}).then(_ => {
// row inserted into the base
// let's query all the players
return users.findAll()
}).then((rows) => {
// rows = [ { username: 'playerunkown', game: 'battlegrounds }]
})
Raw queries
Clay Base runs on Postgres, which allows you to run raw queries in a totally secure environment.
const Base = require('clay-base-sdk')
Base.initialize('PRIVATE_KEY') // private key
Base.query(`SELECT * FROM players WHERE username="unkownplayer" LIMIT 1`).then((rows) => {
// rows = [ { username: 'playerunkown', game: 'battlegrounds }]
})
Querying
We offer a Javascript friendly interface to query rows in a basic way:
const Base = require('clay-base-sdk')
Base.initialize('PRIVATE_KEY') // private key
users.find({
where: {
username: 'playerunkown'
},
order: 'createdAt DESC',
limit: 1
}).then((rows) => {
// rows = [ { username: 'playerunkown', game: 'battlegrounds }]
})
Bugs
Please report bug and issues in the issues tab on Github.
Author
This repository is maintained and published by Clay Labs Inc.