Skip to content

ryapisov/referral-mongo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Referral-mongo

version: Beta

Features

  • The change the referral chain
  • Referral system using mongoDB a distributed General purpose database based on documents

Installation

installing the module

  npm i referral-mongo

installing the database

sudo apt install -y mongodb

sudo systemctl start mongodb

Сonnection

const {
  createReferal,
  getReferrals,
  updateReferal,
  deleteReferral
} = require('referral-mongo')

API create referral without parent

returns a Promise:

createReferal({
  userId: 1,
  data:{example:"your data"}
})

API create referral with parent

returns a Promise:

createReferal({
  userId: 2,
  parentId:1,
  data:{example:"your data"}
})

API get referrals

returns a Promise:

getReferrals(userId:5)

API update referral

returns a Promise:

createReferal({
  userId: 2,
  data:{example:"your data"}
})

API delete referral

returns a Promise:

deleteReferal({
  userId: 2,
  data:{example:"your data"}
})

Set the depth of the referral system. By default three.

export REFERRAL_LEVELS=3

Database address

export REFERRAL_DATA_BASE='mongodb://localhost:27017/referrals'