# tsorimongo

> typescript origami mongo

Latest version **0.3.6** (published 2023-07-03) · MIT license · 0 weekly downloads

## Install

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

## 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.3.6 |
| Published | 2023-07-03 |
| First published | 2022-05-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 160.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Maintainers | vahidhossaini |

## Links

- npm: https://www.npmjs.com/package/tsorimongo
- Repository: https://github.com/origamiicore/ts-modules.git#main
- Homepage: https://github.com/origamiicore/ts-modules/tree/main#readme
- Issues: https://github.com/origamiicore/ts-modules/issues
- npm.io page: https://npm.io/package/tsorimongo

## Dependencies (4)

- [mongodb](https://npm.io/package/mongodb.md) ^4.6.0
- [typescript](https://npm.io/package/typescript.md) ^4.7.2
- [origamicore](https://npm.io/package/origamicore.md) ^3.1.8
- [odata-v4-parser](https://npm.io/package/odata-v4-parser.md) ^0.1.29

## Recent versions

- 0.3.6 (latest) — 2023-07-03
- 0.3.5 — 2023-04-14
- 0.3.4 — 2023-04-14
- 0.3.3 — 2022-09-25
- 0.3.2 — 2022-08-24
- 0.3.1 — 2022-08-14
- 0.3.0 — 2022-07-03
- 0.2.0 — 2022-06-19
- 0.1.13 — 2022-06-19
- 0.1.12 — 2022-06-18
- 0.1.11 — 2022-06-13
- 0.1.10 — 2022-06-13
- 0.1.9 — 2022-06-13
- 0.1.8 — 2022-06-12
- 0.1.7 — 2022-06-11
- … 7 more at https://npm.io/package/tsorimongo/versions

## README

# TypeScript TsOriMongo

## Installation
OriEndpoint requires [OrigamiCore](https://www.npmjs.com/package/origamicore)  to run.
```sh
npm install origamicore
npm install tsorimongo
```

## Samples
[MongoDb CRUD](https://github.com/origamiicore/ts-modules/tree/main/tsorimongo/sample)


### Insert 
```
        var insertData= await coll.InsertOne(new ProfileModel({
            _id:'2',
            firstName:'vahid',
            lastName:'hossaini',
            age:12
        })) 
        var insertManyData= await coll.InsertMany(
            [
                new ProfileModel({
                    _id:'1',
                    firstName:'name 1',
                    lastName:'lastname 1',
                    age:3*1
                }),
                new ProfileModel({
                    _id:'3',
                    firstName:'name 3',
                    lastName:'lastname 3',
                    age:3*3
                }),
                new ProfileModel({
                    _id:'4',
                    firstName:'name 4',
                    lastName:'lastname 4',
                    age:3*4
                }),
            ]
        )
```

### Update 
```
        var updateOneData =await coll.UpdateOne({_id:'1'},{set:{firstName:'name1'},inc:{age:2}})
        var updateManyData =await coll.UpdateMany({age:12},{inc:{age:1}})
        var replaceData=await coll.Replace({_id:'1'},new ProfileModel({age:22,firstName:'r1',lastName:'r2'}))
```

### Delete 
```
        var deleteOneData=await coll.deleteOne({_id:'1'})
        var deleteOneData=await coll.deleteOne({_id:'3'})
        var deleteManyData=await coll.deleteMany({age:13})
```

### Search 
```
        var records:OdataResponse<ProfileModel>;
        records= await coll.search().select(['firstName','age']).find();
        records= await coll.search().count().find();
        records= await coll.search().select(['lastName'])
        .group([
            new SelectModel({func:'sum',name:'age',title:'ageTitle'}),
            new SelectModel({func:'count',name:'age',title:'ageCount'}),
        ]).find();
        records= await coll.search().where({age:{$gt:10}}).find();
        records= await coll.search().where({age:{$lt:10}}).find();
        records= await coll.search().where({age:{$eq:null}}).find();
        records= await coll.search().where({age:{$ne:null}}).find();
        records= await coll.search().where({age:{$lt:10}}).whereAnd({age:{$gt:5}}).find();
        records= await coll.search().where({age:{$lt:10}}).whereOr({age:{$eq:null}}).find();
        records= await coll.search().where({age:{$lt:10}}).whereOr({age:{$eq:null}}).sort(new SortModel({name:'age',type:'desc'})).find();
        records= await coll.search().where({age:{$lt:10}}).whereOr({age:{$eq:null}}).sort(new SortModel({name:'age',type:'asc'})).find();
        records= await coll.search().limit(2).find();
        records= await coll.search().limit(2).skip(1).find();
        records= await coll.search()
        .select(['age','firstName'])
        .where({_id:{$ne:'2'}})
        .odata(new OdataModel({
            $count:true,
            $top:4,
            $skip:1,
            $filter:'age gt 3',
            $orderby:'age desc',
            $select:'age,lastName'     
        })).find();
        var record= await coll.search().where({age:{$ne:null}}).findOne();
```

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