move to bun
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import Database from 'better-sqlite3';
|
||||
import { Database } from 'bun:sqlite';
|
||||
|
||||
const dbName = './db/strimserve.db';
|
||||
|
||||
@@ -6,9 +6,12 @@ const dbName = './db/strimserve.db';
|
||||
const db = new Database(dbName);
|
||||
|
||||
export function getStreams() {
|
||||
const indexData = db.prepare('SELECT id, stream_date, title, tags, length_seconds ' +
|
||||
'FROM Stream ORDER BY id DESC').all();
|
||||
indexData.forEach(stream => {
|
||||
const indexData = db
|
||||
.prepare(
|
||||
'SELECT id, stream_date, title, tags, length_seconds ' + 'FROM Stream ORDER BY id DESC'
|
||||
)
|
||||
.all();
|
||||
indexData.forEach((stream) => {
|
||||
stream['stream_date'] = Date.parse(stream['stream_date']);
|
||||
stream['tags'] = JSON.parse(stream['tags']);
|
||||
});
|
||||
@@ -16,10 +19,14 @@ export function getStreams() {
|
||||
}
|
||||
|
||||
export function getStreamInfo(streamId) {
|
||||
const streamData = db.prepare("SELECT id, stream_date, filename, " +
|
||||
"format, title, description, tags, " +
|
||||
"length_seconds, tracks FROM Stream " +
|
||||
"WHERE id = ?").get(streamId);
|
||||
const streamData = db
|
||||
.prepare(
|
||||
'SELECT id, stream_date, filename, ' +
|
||||
'format, title, description, tags, ' +
|
||||
'length_seconds, tracks FROM Stream ' +
|
||||
'WHERE id = ?'
|
||||
)
|
||||
.get(streamId);
|
||||
streamData['stream_date'] = Date.parse(streamData['stream_date']);
|
||||
streamData['tracks'] = JSON.parse(streamData['tracks']);
|
||||
streamData['tags'] = JSON.parse(streamData['tags']);
|
||||
|
||||
Reference in New Issue
Block a user