@spartan-hc/caps-entities

0.3.1 • Public • Published

CAPS Entities

A library for transforming Entity objects for the hc_crud_caps rust crate.

Install

npm i @spartan-hc/caps-entities

Basic Usage

import crypto from 'crypto';
import { ActionHash, EntryHash } from '@spartan-hc/holo-hash';
import { Entity } from '@spartan-hc/caps-entities';

const post = new Entity({
    "id": new ActionHash( crypto.randomBytes(32) ),
    "action": new ActionHash( crypto.randomBytes(32) ),
    "address": new EntryHash( crypto.randomBytes(32) ),
    "type": "post",
    "content": {
	"message": "Goodbye, world!",
	"published_at": 1696819762583,
	"last_updated": 1696819762602
    }
});

console.log( post );
// Entity {
//     message: 'Goodbye, world!',
//     published_at: 1696819762583,
//     last_updated: 1696819762602
// }

// Hidden properties
console.log( post.$id );        // ActionHash( ... );
console.log( post.$action );    // ActionHash( ... );
console.log( post.$address );   // EntryHash( ... );
console.log( post.$type );      // "post"

Readme

Keywords

none

Package Sidebar

Install

npm i @spartan-hc/caps-entities

Weekly Downloads

0

Version

0.3.1

License

ISC

Unpacked Size

209 kB

Total Files

10

Last publish

Collaborators

  • brisebom