Code Monkey home page Code Monkey logo

paratii-db's Introduction

CircleCI

Paratii-Db aka Paratii-obServer

WORK IN PROGRESS

The Mongodb mirror of the paratii smartcontract data. This is mainly used to make it easier to index and search the video data and do all sorts of aggregations that would be too hard to do on the blockchain data.

Dependencies

This requires MongoDb to work. head over to the download section and install the proper release for your system.

Installation

$ git clone https://github.com/Paratii-Video/paratii-db.git
$ cd paratii-db
$ npm install

# for development (needs Parity node running)
# this command will fail if you don't have previously ran yarn run build:dev on paratii-portal
$ npm run dev

# for production against Paratii Chain
$ npm run start

# Note: You can also use yarn. I'm not gonna judge :)

Testing

First start the mongoDB service:

$ sudo service mongod start

The tests expect a locally running parity node, so start that:

$ npm run parity

And now run the tests in another terminal:

$ npm run test

Documentation

API

REST API are available on db.paratii.video. You can use API also using paratii-lib and paratii.core features, check the docs at:

https://github.com/Paratii-Video/paratii-lib/blob/dev/docs/paratii-core.md

Videos

Get all videos collection:

GET /api/v1/videos

Search in videos collections:

keyword=<keyword>

available indexed (and full text searchable) fields:

  • video
  • description
  • owner
  • uploader.name
  • uplaoder.address
  • tags

Mixed search:

keyword=<keyword>&owner=<address>

Get single video document:

GET /api/v1/videos/<id>

Get related videos collection (TBD):

GET /api/v1/videos/<id>/related

Users

Search in users collection:

GET /api/v1/users

available indexed (and full text searchable) fields:

  • name
  • email

Mixed search (quiet useless at the moment):

keyword=<keyword>&email=<email>

Get user document:

GET /api/v1/users/<id>

Transactions

Search in transactions collection:

GET /api/v1/transactions

available indexed (and full text searchable) fields:

  • from
  • to
  • description

Mixed search:

keyword=<keyword>&description=<description>

Get transaction document:

GET /api/v1/transactions/<id>

Overlooking Blockchain obSERVER

Currently obSERVER is configure to listen to:

module.videoObserver = require('./video')(paratii)
module.userObserver = require('./user')(paratii)
module.transactionObserver = require('./transaction')(paratii)

Collection Model

Transaction:

{
_id: String,
blockNumber: Number,
event: String,
description: String,
from: String,
logIndex: Number,
nonce: Number,
source: String,
to: String,
value: Number
}

Video:

{
_id: String,
title: {type: String},
description: {type: String},
price: Number, // FIXME this should be bignumber.js
src: String,
mimetype: String,
owner: {type: String},
stats: {
likes: Number,
dislikes: Number,
likers: Array,
dislikers: Array
},
uploader: {
name: {type: String},
address: {type: String}
},
tags: {type: [String]}
}

User:

{
_id: {type: String},
name: {type: String},
email: {type: String},
ipfsData: String
}

Mongo indexing

Transaction:

{from: 'text', to: 'text', description: 'text'}

Video:

{title: 'text', description: 'text', owner: 'text', 'uploader.name': 'text', 'uploader.address': 'text', tags: 'text'}

User:

{name: 'text', email: 'text'}

Request cors access

Currently our API have limited cors access. Want to develop a project that use Paratii API? Write us on our beloved telegram channel =)

https://t.me/joinchat/EWZMBQ9mnqJ1--NKHpyF8A

Troubleshooting

If you get an error like MongoError: exception: Unrecognized pipeline stage name: '$sample', you may have a Mongo version < 3.2, and you need to upgrade.

Check the version with mongo --version, and follow the instructions here https://docs.mongodb.com/manual/release-notes/3.2-upgrade/

paratii-db's People

Contributors

eliawk avatar enricocicconi avatar geckoslair avatar jellegerbrandy avatar leeaandrob avatar lorenzo-dev1 avatar ya7ya avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.