# oridatabase

> origamicore database

Latest version **0.0.11** (published 2022-03-04) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.11 |
| Published | 2022-03-04 |
| First published | 2019-11-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 67 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | vahidhossaini |
| Keywords | origamicore, database, mongodb, mysql |

## Links

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

## 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

- 0.0.11 (latest) — 2022-03-04
- 0.0.10 — 2021-12-14
- 0.0.9 — 2020-07-09
- 0.0.8 — 2020-04-07
- 0.0.7 — 2020-02-16
- 0.0.6 — 2019-12-03
- 0.0.5 — 2019-12-03
- 0.0.4 — 2019-12-03
- 0.0.3 — 2019-11-29
- 0.0.2 — 2019-11-17
- 0.0.1 — 2019-11-16

## README

# Description
This module connect to database and CRUD
supporetd database:
- mongodb
- mysql
- sqlserver (not supported yet)


# Configuration
 
    {
        name:'database',
        connection:[
            {
                name:'default',//name of connection
                type:'mongodb',//database type: 'mongodb','mysql','sqlserver'
                host:'dbexample.com',
                username:'{username}',
                password:'{password}',
                database:'{database name}'
            }
        ]
    }
    
# How to use

### Save
if object is exist update else insert

    global.db.Save('{connectionName}','{table or collection Name}',[{key list}],object,{Function})
    
example

    global.db.Save('default','news',['title'],{title:'hi',createAt:new Date()},(error,data)=>{
        // After run Save
    })
    
### Update    

    global.db.Update('{connectionName}','{table or collection Name}',[{key list}],object,{Function})
    
example

    global.db.Update('default','news',['title'],{title:'hi',createAt:new Date()},(error,data)=>{
        // After run Update
    })
    
### Delete 

    global.db.Delete('{connectionName}','{table or collection Name}',[{key list}],object,{Function})
    
example

    global.db.Delete('default','news',['title'],{title:'hi'},(error,data)=>{
        // After run Delete
    })

### Search
        
    global.db.Search('{connectionName}','{table or collection Name}',{query},{odata},func)
    
Suppose we have an object like this

    {
        firstName:string
        lastrName:string
        age:number
        score:number
    }
    
If you want to use Odata:[Odata Doc](http://www.odata.org/documentation/)


If you want to use "query" :

- select

examples:

    select:['firstName','lastrName','age']

    select : ['age',{type:'function',name:'sum',field:'score',title:'totalScore'}]
        
- order by

example:
            
    order:[['age','ASC'],['score','DESC']]      

- where

examples:

grater than

    where:{age:{$gt:12}}    Mean age>12
    
grater or equal than

    where:{age:{$gte:12}}   Mean age>=12
    
lower than

    where:{age:{$lt:12}}    Mean age<12
    
lower or equal than

    where:{age:{$lte:12}}   Mean age<=12
    
equal than

    where:{age:{$eq:12}}   Mean age==12 
    where:{age:12}   Mean age==12 
    
not equal than

    where:{age:{$ne:12}}   Mean age<>12 | age!=12  
    
or than

    where:{$or:[{age:12},{sccore:{$gte:300}}]}   Mean (age==12 or score>=300) 
    
and than

    where:{$and:[{age:12},{sccore:{$gte:300}}]}   Mean (age==12 and score>=300) 
    
    
sample of Search    

    global.db.Search('default','UserPoint',{
                                                where:{$or:[{age:12},{sccore:{$gte:300}}]},
                                                select:['age',{type:'function',name:'sum',field:'score',title:'totalScore'}],
                                                order:[['age','ASC']]
                                           },
                                           {
                                                $top:10,
                                                $skip:12,
                                                $count:true
                                           },(error,data){
                                                //data.value is list of array
                                                var totals=data.value
                                                //if in odata count=true , return count of data without odata $top and $skip
                                                var totalCount=data.count
                                           })

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