1.1.4 • Published 2 years ago

infinitedb v1.1.4

Weekly downloads
-
License
AGPL-3.0-only
Repository
github
Last release
2 years ago

InfiniteDB

Coverage lines Coverage functions Coverage branches Coverage statements

Client

Installation

Run npm install infinitedb in your project

Require client using

const InfiniteDB = require('infinitedb')

Usage

List databases

let host = { hostname: '127.0.0.1', port: 8176 }

InfiniteDB.listDatabases(host).then(result => {
    console.log(result)
}).then(error => {
    console.log(error)
})

Create database

let host = { hostname: '127.0.0.1', port: 8176 }
let responsibilities = { number: { start:0, end: 10000 } }

InfiniteDB.createDatabase(host, 'DBNAME', responsibilities).then(result => {
    console.log(result)
}).catch(error => {
    console.log(error)
})

Connect to database

let host = { hostname: '127.0.0.1', port: 8176 }

let database = new InfiniteDB(host, 'DBNAME')
database.connect().then(() => {
    console.log('Connected to database!')
}).catch(error => {
    console.log(error)
})

List tables

database.listTables.then(result => {
    console.log(result)
}).catch(error => {
    console.log(error)
})

Create table

For fields syntax please look at Server documentation

let fields = {}

database.createTable('TABLENAME', fields).then(result => {
    console.log(result)
}).catch(error => {
    console.log(error)
})

Insert into table

let object = {}

database.insert('TABLENAME', object).then(result => {
    console.log(result)
}).catch(error => {
    console.log(error)
})

Query from table

For request syntax please look at Server documentation

let request = {}

database.get('TABLENAME', request).then(result => {
    console.log(result)
}).catch(error => {
    console.log(error)
})

Server

Installation

Clone this repo https://github.com/MeshSocialNetwork/InfiniteDB.git
Run npm install
Create directory database/
Create config file database/config.json with content:
{ "hostname": "127.0.0.1", "port": "8176" }

API

GET /databases

Returns list of databases

POST /database

Create a new database

Request body:

{
  "name": "DBNAME",
  "responsibilities": { "start": 0, "end": 10000 }
}

POST /database/:name/join

Join an existing database (from another peer)

Request body:

{
  "peer": {
    "hostname": "127.0.0.1",
    "port": "8176"
  },
  "responsibilities": { "start": 0, "end": 10000 },
  "joinKey": "JOINKEY"
}

The joinKey can be found in database/DBNAME/database.json

GET /database/:name

Get tables with fields and responsibilities of database

GET /datbase/:name/tables

Get list of table names for database

POST /database/:name/table

Create new table

Request body:

{
  "name": "tablename"
  "fields": {
    "testfield": {
       "type": "text"
    },
    
    "testfield2": {
        "type": "text",
        "indexed": true
        "unique": true
    },
    
    "testfield3": {
        "type": "text",
        "indexed": true,
        "distributed": true
    },
    
    "testfield4": {
        "type": "text",
        "indexed": true,
        "distributed": true,
        "external": true
    },
    
    "testfield5": {
        "type": "number",
        "indexed": true,
        "distributed": true
    },
    
    "testfield6": {
        "type": "boolean",
        "indexed": true
    }
  }
}

POST /database/:name/table/:tableName/get

Query table

Request body:

{
  "where": {
    "field": "testfield2",
    "operator": "=",
    "value": "testvalue",
    
    "and": {
       "field": "testfield5",
       "operator": ">",
       "value": 10
       
       "or": {
         "field": "testfield5",
         "operator": "<",
         "value": 10,
         
         "or": {
            "field": "testfield5",
            "operator": "><",
            "value": "10-20",
            
            "and": {
               "field": "testfield4",
               "operator": "match",
               "value": "testmatch"
            }
         }
       }
    }
  },
  
  "implement": [
    {
      "from": {
        "table": "othertable",
        "field": "otherfield"
      },
      "field": "testfield",
      "as": "testalias"
    }
  ],
  
  "sort": {
    "field": "testfield5",
    "direction": "DESC"
  },
  
  "skip": 0,
  "limit": 50
}

POST /database/:name/table/:tableName/insert

Insert into table

Request body:

{
  "object": {
    "fieldname": "fieldvalue"
  }
}

POST /database/:name/table/:tableName/update

Update existing object in table (must have indexed unique field)

Request body:

{
   "object": {
      "indexedUniqueField", "value"
   }
}
1.1.4

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.0.29

2 years ago

1.0.28

2 years ago

1.0.32

2 years ago

1.0.31

2 years ago

1.0.30

2 years ago

1.0.19

2 years ago

1.0.18

2 years ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.22

2 years ago

1.0.21

2 years ago

1.0.20

2 years ago

1.0.26

2 years ago

1.0.24

2 years ago

1.0.23

2 years ago

1.0.27

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago