GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - Hypertopic/lib-node: Hypertopic NodeJS library

BranchesTags
Open more actions menu

Latest commit

 

History

70 Commits
70 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
__tests__
__tests__
 
 
src
src
 
 
.gitignore
.gitignore
 
 
.npmignore
.npmignore
 
 
README.md
README.md
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 

Repository files navigation

Client library for the Hypertopic protocol

Requirements

  • Install and run Argos (on port 80) with test data.

Install

npm install hypertopic

Use

Set the services to be called

const hypertopic = require('hypertopic');

let db = hypertopic([
  "http://localhost",
  "https://steatite.utt.fr"
]);

const _log = (x) => console.log(JSON.stringify(x, null, 2));
const _error = (x) => console.error(x.message);

Send distributed requests

  • on a user
db.getView('/user/vitraux')
  .then(_log);
  • on an item
db.getView('/item/Vitraux - Bénel/85bb03f5e4930f3b9d1ef9afbfa92421b8e2e23b')
  .then(_log);
  • on a corpus (with all its items)
db.getView('/corpus/Vitraux - Bénel')
  .then(_log);
  • on a viewpoint
db.getView('/viewpoint/a76306e4f17ed4f79e7e481eb9a1bd06')
  .then(_log);
  • on several of them
db.getView(['/corpus/Vitraux - Bénel','/corpus/Vitraux - Recensement'])
  .then(_log);
  • on all corpora and viewpoints of a user
db.getView('/user/vitraux')
  .then(x => [
    ...x.vitraux.viewpoint.map(y => `/viewpoint/${y.id}`),
    ...x.vitraux.corpus.map(y => `/corpus/${y.id}`)
  ])
  .then(db.getView)
  .then(_log);

Update objects with generic methods

  • Create an object (with an automatic ID)
db.auth('alice', 'whiterabbit')
  .post({item_name:'Bond', item_corpus:'TEST'})
  .then(_log)
  .catch(_error);
  • Create an object with a given ID
db.auth('alice', 'whiterabbit')
  .post({_id:'007', item_name:'Bond', item_corpus:'TEST'})
  .then(_log)
  .catch(_error);
  • Update an object
db.auth('alice', 'whiterabbit')
  .get({_id:'007'})
  .then(x => Object.assign(x, {item_name:'James Bond'}))
  .then(db.post)
  .then(_log)
  .catch(_error);
  • Delete an object with update conflict detection
db.auth('alice', 'whiterabbit')
  .delete({_id:'007', _rev:'1-xxxxxxxxx'})
  .then(_log)
  .catch(_error);
  • Delete an object with no conflict detection (to be used with caution!)
db.auth('alice', 'whiterabbit')
  .get({_id:'007'})
  .then(db.delete)
  .then(_log)
  .catch(_error);

Update (or create) Hypertopic objects (experimental)

  • Item attributes
db.auth('alice', 'whiterabbit')
  .item({_id:'007', item_corpus:'agents'})
  .setAttributes({item_name:'James Bond', weapon:'Walther PPK'})
  .then(_log)
  .catch(_error);
db.auth('alice', 'whiterabbit')
  .item({_id:'007', item_corpus:'agents'})
  .unsetAttribute('weapon')
  .then(_log)
  .catch(_error);
  • Item topics
db.auth('alice', 'whiterabbit')
  .item({_id:'007', item_corpus:'agents'})
  .setTopic('topic-octopussy', 'viewpoint-missions')
  .then(_log)
  .catch(_error);
db.auth('alice', 'whiterabbit')
  .item({_id:'007', item_corpus:'agents'})
  .unsetTopic('topic-octopussy')
  .then(_log)
  .catch(_error);
  • Item resources
db.auth('alice', 'whiterabbit')
  .item({_id:'007', item_corpus:'agents'})
  .setResource('hello.txt', 'text/plain', 'My name is Bond, James Bond.')
  .then(_log)
  .catch(_error);
db.auth('alice', 'whiterabbit')
  .item({_id:'007', item_corpus:'agents'})
  .unsetResource('hello.txt')
  .then(_log)
  .catch(_error);
  • Item links
db.auth('alice', 'whiterabbit')
  .item({_id:'007', item_corpus:'agents'})
  .setLink('has for superior', 'executives', 'M')
  .then(_log)
  .catch(_error);
db.auth('alice', 'whiterabbit')
  .item({_id:'007', item_corpus:'agents'})
  .unsetLink('has for superior', 'executives', 'M')
  .then(_log)
  .catch(_error);

About

Hypertopic NodeJS library

www.npmjs.com/package/hypertopic

Topics

couchdbdistributed-databasees2015promise

Resources

Readme
Activity
Custom properties

Stars

4 stars

Watchers

6 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.