[**@s4ai/core Documentation v0.3.23**](../../../README.md)

***

[@s4ai/core Documentation](../../../modules.md) / [infrastructure/postgresql-persistence](../README.md) / PostgreSQLPersistence

# Class: PostgreSQLPersistence

Defined in: infrastructure/postgresql-persistence.js:16

## Constructors

### Constructor

> **new PostgreSQLPersistence**(`config?`): `PostgreSQLPersistence`

Defined in: infrastructure/postgresql-persistence.js:17

#### Parameters

##### config?

#### Returns

`PostgreSQLPersistence`

## Properties

### initialized

> **initialized**: `boolean`

Defined in: infrastructure/postgresql-persistence.js:67

***

### pool

> **pool**: `any`

Defined in: infrastructure/postgresql-persistence.js:66

## Methods

### close()

> **close**(): `Promise`\<`void`\>

Defined in: infrastructure/postgresql-persistence.js:342

Close connection pool

#### Returns

`Promise`\<`void`\>

***

### get()

> **get**(`key`): `Promise`\<`any`\>

Defined in: infrastructure/postgresql-persistence.js:210

Retrieve knowledge from database

#### Parameters

##### key

`any`

#### Returns

`Promise`\<`any`\>

***

### getStats()

> **getStats**(): `Promise`\<\{ \}\>

Defined in: infrastructure/postgresql-persistence.js:317

Get statistics

#### Returns

`Promise`\<\{ \}\>

***

### initialize()

> **initialize**(): `Promise`\<`void`\>

Defined in: infrastructure/postgresql-persistence.js:78

Initialize database schema

#### Returns

`Promise`\<`void`\>

***

### logDecision()

> **logDecision**(`decisionType`, `decisionData`, `confidence?`): `Promise`\<`any`\>

Defined in: infrastructure/postgresql-persistence.js:246

Log autonomous decision

#### Parameters

##### decisionType

`any`

##### decisionData

`any`

##### confidence?

`number` = `0.8`

#### Returns

`Promise`\<`any`\>

***

### logInsight()

> **logInsight**(`insightType`, `insightText`, `confidence?`): `Promise`\<`any`\>

Defined in: infrastructure/postgresql-persistence.js:268

Log learning insight

#### Parameters

##### insightType

`any`

##### insightText

`any`

##### confidence?

`number` = `0.8`

#### Returns

`Promise`\<`any`\>

***

### migrateFromJSON()

> **migrateFromJSON**(`jsonDir?`): `Promise`\<`void`\>

Defined in: infrastructure/postgresql-persistence.js:290

Migrate from JSON files to database

#### Parameters

##### jsonDir?

`string` = `'./backend/s4ai-knowledge-base/'`

#### Returns

`Promise`\<`void`\>

***

### query()

> **query**(`pattern`): `Promise`\<`any`\>

Defined in: infrastructure/postgresql-persistence.js:225

Query knowledge by pattern

#### Parameters

##### pattern

`any`

#### Returns

`Promise`\<`any`\>

***

### set()

> **set**(`key`, `value`): `Promise`\<`any`\>

Defined in: infrastructure/postgresql-persistence.js:189

Store knowledge in database

#### Parameters

##### key

`any`

##### value

`any`

#### Returns

`Promise`\<`any`\>
