> For the complete documentation index, see [llms.txt](https://guilhermesantos.gitbook.io/niro-health/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://guilhermesantos.gitbook.io/niro-health/modules/core/sqlite.md).

# Sqlite

This service is used to interact with the Redis database.

### Imports

{% tabs %}
{% tab title="Service" %}

```typescript
import { SqliteService } from 'niro-health';
```

{% endtab %}

{% tab title="Module" %}

```typescript
import { SqliteModule } from 'niro-health';
```

{% endtab %}

{% tab title="Interface" %}

```typescript
import type { ISqliteService } from 'niro-health';
```

{% endtab %}
{% endtabs %}

### Method of Use

To use this module, you need to inject it into the desired service.

{% code overflow="wrap" %}

```typescript
import { Module } from '@nestjs/common';
import {
  AppHostService,
  SqliteService,
  ConfigurationService,
  ValidatorRegexpService,
  StringExService,
  DebugService,
} from 'niro-health';
import { AppController } from './app.controller';
import { AppService } from './app.service';

@Module({
  controllers: [AppController],
  providers: [
    AppService,
    {
      provide: 'IAppHostService',
      useClass: AppHostService,
    },
    {
      provide: 'ISqliteService',
      useClass: SqliteService,
    },
    {
      provide: 'IConfigurationService',
      useClass: ConfigurationService,
    },
    {
      provide: 'IValidatorRegexpService',
      useClass: ValidatorRegexpService,
    },
    {
      provide: 'IStringExService',
      useClass: StringExService,
    },
    {
      provide: 'IDebugService',
      useClass: DebugService,
    },
  ],
})
export class AppModule {}
```

{% endcode %}

Injecting the module into our service.

```typescript
import { Inject, Injectable } from '@nestjs/common';
import type { IAppHostService, ISqliteService } from 'niro-health';

@Injectable()
export class AppService {
  constructor(
    @Inject('IAppHostService')
    private readonly appHostService: IAppHostService,
    @Inject('ISqliteService')
    private readonly sqliteService: ISqliteService,
  ) {}

  async enableShutdownHooks() {
    await this.sqliteService.enableShutdownHooks(this.appHostService.app);
  }
}
```

Modifying our <mark style="color:blue;">**`main.ts`**</mark>

{% code title="main.ts" %}

```typescript
import { NestFactory } from '@nestjs/core';
import { AppModule } from '@/app.module';
import { Logger } from '@nestjs/common';
import { AppHostModule, AppHostService } from 'niro-health';
import { AppModule } from './app.module';
import { AppService } from './app.service';

(async function bootstrap() {
  const app = await NestFactory.create(AppModule, {
    logger: new Logger('NestApplication', {
      timestamp: true,
    }),
    cors: true,
  });
  app.select(AppHostModule).get(AppHostService).setApp(app);
  app.select(AppModule).get(AppService).enableShutdownHooks();
})();
```

{% endcode %}

### With dependencies

You will need to inject the following interfaces.

<table><thead><tr><th width="308">Interface</th><th>Service</th></tr></thead><tbody><tr><td><code>IConfigurationService</code></td><td><a href="/niro-health/modules/configuration.md">Link to Service documentation</a></td></tr><tr><td><code>IValidatorRegexpService</code></td><td><a href="/niro-health/modules/validator-regexp.md">Link to Service documentation</a></td></tr><tr><td><code>IStringExService</code></td><td><a href="/niro-health/modules/stringex.md">Link to Service documentation</a></td></tr><tr><td><code>IDebugService</code></td><td><a href="/niro-health/modules/debug.md">Link to Service documentation</a></td></tr></tbody></table>

### Properties

<table><thead><tr><th>Property</th><th width="121.33333333333331" align="center">Scope</th><th>Description</th></tr></thead><tbody><tr><td><code>app</code></td><td align="center"><code>public</code></td><td><code>This is instance of application.</code></td></tr><tr><td><code>_db</code></td><td align="center"><code>private</code></td><td><code>This is the major component of sqlite3. Use it to connect to a standalone Sqlite server or Sentinels.</code></td></tr><tr><td><mark style="color:blue;"><strong>get</strong></mark> <code>_dbName</code></td><td align="center"><code>private</code></td><td><code>This method is used to get database name.</code></td></tr><tr><td><mark style="color:blue;"><strong>get</strong></mark> <code>db</code></td><td align="center"><code>public</code></td><td><code>This method is used to get database instance.</code></td></tr></tbody></table>

### Methods

<table><thead><tr><th width="316.3333333333333">Method</th><th width="117" align="center">Scope</th><th>Description</th></tr></thead><tbody><tr><td><code>_connectionLogs</code></td><td align="center"><code>private</code></td><td><code>This method is used to log connection events.</code></td></tr><tr><td><code>shutdown</code></td><td align="center"><code>public</code></td><td><code>This method is used to shutdown application.</code></td></tr><tr><td><code>onApplicationShutdown</code></td><td align="center"><code>public</code></td><td><code>This method is called before the application shutdown.</code></td></tr><tr><td><code>enableShutdownHooks</code></td><td align="center"><code>public</code></td><td><code>This method is used to enable shutdown hooks.</code></td></tr></tbody></table>
