npm package: @moero/database_ts
Description: The database methods using typescript. ### packages ```text luxon: Get current time. mongodb: Database package. ``` ### mongodb ```src/mongo``` ### Startup 1. Setup the options of connection ```typescript const optionsOfConnection = { host: "127.0.0.1",  
Author: moero
Latest version: 1.0.0
Deprecated: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

# Diheko Database package
The database methods using typescript. 
### packages
```text
luxon: Get current time. 
mongodb: Database package.
```
### mongodb ```src/mongo```
### Startup
1. Setup the options of connection
```typescript
const optionsOfConnection = {
    host: "127.0.0.1",  // Host of mongodb server
    port: 0,            // Port of this connection  
    user: "user",       // User's name 
    passwd: "passwd",   // User's password
    defaultDB: "test",  // Defualt database for identity or do some db methods
    params:{}           // Params if the connection has
};
```
2. Construct the mongo object
```typescript
const client = new Mongo(optionsOfConnection);
```
3. Start the mongodb
```typescript
// Without await
client.connect().then(
    (a: typeof client)=>{
        // Script
    }).catch(
    (err: Error)=> {
        // Error 
    }).finally(()=>{
        // Finally
});

// With await
await client.connect();
```

### Database Methods
Before call the database methods, it is necessary to define the interface specification for the data.
```typescript
interface INameOfInterface{
    ColumnName1: DataType1,
    ColumnName2: DataType2,
    ColumnName3: DataType3,
    //...
};
const yourData : INameOfInterface = {
    ColumnName1: Data1,
    ColumnName2: Data2,
    ColumnName3: Data3,
    //...
};
```
Also you should define the collection
```typescript
const yourTable = {
    db: "",         // Name of your database
    collection: ""  // Name of table inside your database
};
```

### 1. select
Getting data from database

```typescript
client.select(
    yourTable,                      // The collection which you want to search
    yourData,                       // The filter for this search
    ["ColumnName1", "ColumnName2"], // Projection that you want to show. (null to show all)
    {
        sort: ["ColumnName1"],      // Specify sort orders
        limit: 1,                   // Data count limit
        offset: 1,                  // Return data from the nth row onwards
        maxTimeMS: 15               // Setup this process timeout (ms)
    }
);
```
### 2. insert
Insert data into database
```typescript
client.insert(
    yourTable,  // The collection which you want to insert
    [yourData]  // The data for this insert
);
```

### 3. update
Modify data from database
```typescript
client.update(
    yourTable,  // The collection which you want to update
    yourData1,  // The filter which you want to modify
    yourData2   // The data what will modify to
);
```


### 4. delete
Delete data from database
```typescript
client.delete(
    yourTable,  // The collection which you want to delete someting
    yourData,   // The data which you want to be removed
    true        // safe delect if you want
);
```

### 5. delete undo
Recover the safe-deleted data
```typescript
client.deleteUndo(
    yourTable,  // The collection which you want to recover someting
    yourData    // The data which you want to be recovered
);
```
### 6. has
Check data if exist
```typescript
client.has(
    yourTable,  // The collection which you want to check
    yourData   // The data which you want to check
);
```