hyper63 playground for data service

node v10.23.3
version: 2.0.0
endpointsharetweet
Welcome to hyper63 playground for the data service, this notebook lets you run live requests against the https://play.hyper63.com service.
// first we need to setup some variables const token = `eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJoeXBlcjYzIiwiaWF0IjoxNjExMTYwMjMwLCJleHAiOjI1NTc4ODgyMzB9.HzWKLVs_cHKvCQ1l-cA2mkle63BwAD9C1Ee5-WagVDw` const url = 'https://play.hyper63.com' const fetch = require('node-fetch')
Datastore Commands * Create Datastore
// create movies datastore await (await fetch(`${url}/data/movies`, { method: 'PUT', headers: { Authorization: `Bearer ${token}`}})).json()
* Create Document
const movie = { id: '1', type: 'movie', title: 'Ghostbusters' } await (await fetch(`${url}/data/movies`, { method: 'POST', headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${token}` }, body: JSON.stringify(movie) })).json()
* Get Document
await (await fetch(`${url}/data/movies/1`, { headers: {Authorization: `Bearer ${token}`}})).json()
* Upsert Document By using the PUT method we can create or update a document in the data store
await (await fetch(`${url}/data/movies/1`, { method: 'PUT', headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ id: '1', title: 'Ghostbusters', type: 'movie', year: '1984' }) })).json()
await (await fetch(`${url}/data/movies/1`, { headers: {Authorization: `Bearer ${token}`}})).json()
* Add more documents
const movies = [ { id: '2', title: 'Groundhog Day', type: 'movie', year: '1993'}, { id: '3', title: 'What about Bob?', type: 'movie', year: '1991'}, { id: '4', title: 'Caddyshack', type: 'movie', year: '1980'}] await Promise.all(movies.map(movie => fetch(`${url}/data/movies`, { method: 'POST', headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${token}` }, body: JSON.stringify(movie) }).then(res => res.json())))
* Query Datastore
(await (await fetch(`${url}/data/movies/_query`, { method: 'POST', headers: {'Content-Type': 'application/json', Authorization: `Bearer ${token}` }, body: JSON.stringify({ selector: { year: { $gt: '1990' } } }) })).json()).docs
* Delete Document
await (await fetch(`${url}/data/movies/1`, { method: 'DELETE', headers: {Authorization: `Bearer ${token}`}})).json()
* Delete Database
// uncomment to delete datastore // await (await fetch(`${url}/data/movies`, { method: 'DELETE', headers: {Authorization: `Bearer ${token}`}})).json()
Loading…

no comments

    sign in to comment