w3db-v2
TypeScript icon, indicating that this package has built-in type declarations

2.0.19 • Public • Published

W3DB-V2 - DECENTRALIZED DATABASE

W3DB-V2 is a decentralised database uses IPFS for managing data

Usage

go to w3db-v2 official page and create app for your project

install this package in your project directory

   # Yarn

   $ yarn add w3db-v2

OR

  # npm

  $ npm i w3db-v2

Creating W3DB-V2 Instance

    const { W3dbV2 } = require("w3db-v2")

    const config = {
       address : // Your Wallet address
       projectId   : // Your ProjectId 
       secret: // Your project secret 
       mumbaiRPC     : // Your polygon mumbai rpc url
    }

    const db = new W3dbV2(config);

     

ADDING NEW DOCUMENT

// adding new collection

const userCollection = db.collection("Users");

//

const doc = userCollection.add({ id: "1233434854323485",firstName: "JOHN", lastName: "DOE" });

GET ENTIRE COLLECTION

  const docs =   userCollection.get({ });

GET A PARTICULAR DOCUMENT

  const docs =  userCollection.get({ id: "1233434854323485" });

   // will fetch list in which the "0x92810381801080313" will be in the 'likes' array
  const docs =  userCollection.get({ $includes: { likes : "0x92810381801080313" }});

UPDATING A PARTICULAR DOCUMENT

 const isSuccess =  userCollection.update({ id: "1233434854323485" },{ lastName: "WICK" });

DELETING A PARTICULAR DOCUMENT

 const deletedId =  userCollection.deleteOne({ id: "1233434854323485" });

DELETING A COLLECTION

  const isSuccess = userCollection.deleteAll()

GET IPFS

   // returns hash of ipfs
  const hash = await db.getIPFS()

  // returns gateway url of IPFS
  const gateway = await db.getIPFS(true)

Package Sidebar

Install

npm i w3db-v2

Weekly Downloads

6

Version

2.0.19

License

MIT

Unpacked Size

39.5 kB

Total Files

11

Last publish

Collaborators

  • pranavpadmanabhan