1.3.0 • Published 6 months ago
@storecraft/database-postgres v1.3.0
Storecraft Postgres driver
Official Postgres driver for StoreCraft using pg package.
npm i @storecraft/database-postgresusage
import 'dotenv/config';
import http from "node:http";
import { App } from '@storecraft/core'
import { NodePlatform } from '@storecraft/core/platform/node';
import { NodeLocalStorage } from '@storecraft/core/storage/node'
import { Postgres } from '@storecraft/database-postgres';
import { migrateToLatest } from '@storecraft/database-sql-base/migrate.js'
const app = new App(
{
auth_admins_emails: ['admin@sc.com'],
}
)
.withPlatform(new NodePlatform())
.withDatabase(
new Postgres({
pool_config: {
host: process.env.POSTGRES_HOST,
port: parseInt(process.env.POSTGRES_PORT),
user: process.env.POSTGRES_USER,
password: process.env.POSTGRES_PASSWORD,
}
})
)
.withStorage(new NodeLocalStorage('storage'))
.init();
await migrateToLatest(app.__show_me_everything.db, false);
await app.__show_me_everything.vector_store.createVectorIndex();
http.createServer(app.handler).listen(
8000,
() => {
app.print_banner('http://localhost:8000');
}
); Storecraft will search the following env variables
POSTGRES_USER='admin'
POSTGRES_PASSWORD='admin'
POSTGRES_PORT=6432
POSTGRES_HOST='localhost'So, you can instantiate with empty config
.withDatabase(
new Postgres()
)Testing Locally
- First start a
postgresserver First, make sure you havedockerinstalled, Then, run
npm run database-postgres:docker-compose-up- create Environment
create .env file with
POSTGRES_USER='admin'
POSTGRES_PASSWORD='admin'
POSTGRES_PORT=6432
POSTGRES_HOST='localhost'- Run
tests/runner.test.js
npm run database-postgres:testAuthor: Tomer Shalev <tomer.shalev@gmail.com>1.0.18
7 months ago
1.0.17
7 months ago
1.0.16
7 months ago
1.2.5
6 months ago
1.3.0
6 months ago
1.0.15
7 months ago
1.0.14
7 months ago
1.0.13
7 months ago
1.0.11
8 months ago
1.0.12
8 months ago
1.0.10
9 months ago
1.0.9
9 months ago
1.0.8
9 months ago
1.0.7
10 months ago
1.0.6
12 months ago
1.0.5
1 year ago
1.0.4
1 year ago
1.0.3
1 year ago
1.0.2
1 year ago
1.0.1
1 year ago