db create
This commit is contained in:
parent
19ae57d449
commit
809fe18090
9 changed files with 93 additions and 35 deletions
23
src/components/db-utils.tsx
Normal file
23
src/components/db-utils.tsx
Normal file
|
@ -0,0 +1,23 @@
|
|||
import { Surreal } from 'surrealdb.js';
|
||||
require('dotenv');
|
||||
|
||||
const db = new Surreal();
|
||||
|
||||
export async function initConnection(): Promise<Surreal> {
|
||||
try {
|
||||
db.connect(process.env.DB_PORT + '/rpc', {
|
||||
namespace: 'url',
|
||||
database: 'url',
|
||||
|
||||
auth: {
|
||||
username: process.env.DB_USER,
|
||||
password: process.env.DB_PASSWORD,
|
||||
scope: '',
|
||||
},
|
||||
});
|
||||
} catch (e) {
|
||||
console.error('ERROR', e);
|
||||
}
|
||||
|
||||
return db;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue