# grantha

> This is an API to connect with Grantha Server: https://db.mrsajjal.com

Latest version **1.0.6** (published 2020-08-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install grantha
pnpm add grantha
yarn add grantha
bun add grantha
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.6 |
| Published | 2020-08-27 |
| First published | 2020-08-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 6.5 KB |
| Known vulnerabilities | 0 (+25 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Sajjal Neupane {https://mrsajjal.com} |
| Maintainers | mrsajjal |
| Keywords | mognodb, database as a service, DBAS, mongodb as a service, mrsajjal, mrsajjal dbas, nosql dbas, grantha |

## Links

- npm: https://www.npmjs.com/package/grantha
- Repository: https://github.com/sajjal/grantha
- Homepage: https://github.com/sajjal/grantha#readme
- Issues: https://github.com/sajjal/grantha/issues
- npm.io page: https://npm.io/package/grantha

## Dependencies (1)

- [axios](https://npm.io/package/axios.md) ^0.20.0

## Alternatives

- [angular-pipes](https://npm.io/package/angular-pipes.md) — 5.6K weekly downloads
- [@ng-web-apis/midi](https://npm.io/package/@ng-web-apis/midi.md) — 2.6K weekly downloads
- [happn-3](https://npm.io/package/happn-3.md) — 1.6K weekly downloads
- [@opensip-cli/lang-go](https://npm.io/package/@opensip-cli/lang-go.md) — 1.2K weekly downloads
- [mongoose-typescript](https://npm.io/package/mongoose-typescript.md) — 85 weekly downloads

## Recent versions

- 1.0.6 (latest) — 2020-08-27

## README

# Welcome to Grantha!

This is an **API** to connect with Grantha Server: `https://db.mrsajjal.com`<br/>
**Grantha** is a Database as a Service (DBaaS) platform developed by _Sajjal Neupane_ `https://mrsajjal.com`

<br/>

#### This API can be used to perform the following operations on Grantha Server!

- Create Records
- Read Records
- Search Records
- Update Records
- Remove Records
- Create Indexes

<br/>

# Installation

`npm i grantha`

<br/>

## Create a Record on a Collection

```
const  db = require("grantha");

const  token = "aab5feca1e9c2770f3a711efe2f2388d1614cb0afe3e04";

const  record = {
                  token: token,
                  collection: "userInfo",
					data: {
						name: "John",
						age: "20",
					},
				};

db.addData(record);

// Adds {name: "John", age: "20"} to the "UserInfo" collection
```

<br/>

## Get all Records from a Collection

```
const  db = require("grantha");

const  token = "aab5feca1e9c2770f3a711efe2f2388d1614cb0afe3e04";

const  record = {
                  token: token,
                  collection: "userInfo",
				};

db.getData(record);

// Returns all records from "UserInfo" collection
```

<br/>

## Search for Records on a Collection

```
const  db = require("grantha");

const  token = "aab5feca1e9c2770f3a711efe2f2388d1614cb0afe3e04";

const  record = {
                  token: token,
                  collection: "userInfo",
					data: {
						age: "20",
					},
				};

db.searchData(record);

// Returns all mathching records where {age: "20"} from "UserInfo" collection
```

> **ProTip:** You can use any **MongoDB find()** properties.

<br/>

## Update a Record on a Collection

```
const  db = require("grantha");

const  token = "aab5feca1e9c2770f3a711efe2f2388d1614cb0afe3e04";

const  record = {
                  token: token,
                  collection: "userInfo",
                  id:"5f47f18ed1637ce1a3942f72",
					data: {
						name:"Henry"
						age: "25",
					},
				};

db.updateData(record);

// Updates record with {id: "5f47f18ed1637ce1a3942f72"} from "UserInfo" collection
```

<br/>

## Remove a Record from a Collection

```
const  db = require("grantha");

const  token = "aab5feca1e9c2770f3a711efe2f2388d1614cb0afe3e04";

const  record = {
                  token: token,
                  collection: "userInfo",
                  id:"5f47f18ed1637ce1a3942f72",
				};

db.removeData(record);

// Removes record with {id: "5f47f18ed1637ce1a3942f72"} from "UserInfo" collection
```

<br/>

## Create an Index on a Collection

```
const  db = require("grantha");

const  token = "aab5feca1e9c2770f3a711efe2f2388d1614cb0afe3e04";

const  record = {
                  token: token,
                  collection: "userInfo",
                  data:{
		                  name:1
	                  },
				};

db.createIndex(record);

// Creates an Index on "UserInfo" collection with "name" sorted in ascending order.
```

<br/>

## Summary

Here is the summary of all the available functions:

| Function       | Input                                               | Operation                                            |
| -------------- | --------------------------------------------------- | ---------------------------------------------------- |
| addData()      | `token, collection_name, data-to-add`               | Creates a record on a Collection                     |
| getData()      | `token, collection_name`                            | Returns all records from a Collection                |
| searchData()   | `token, collection_name, data-to-search`            | Returns all the matching records from a Collection   |
| updateData()   | `token, collection_name, record-id, data-to-update` | Updates record with given-id on a Collection         |
| removeRecord() | `token, collection_name, record-id`                 | Removes record with given-id from a Collection       |
| createIndex()  | `token, collection_name, index-info`                | Creates an Index based on index-info on a collection |

> **Note:** Input must be a valid JSON.

##

With Love,<br/>
**Sajjal**<br/>
`https://mrsajjal.com`<br/>
`https://github.com/sajjal`

---
_Source: https://npm.io/package/grantha · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
