Zum Hauptinhalt springen
Echtzeit-Radar & Feeds
Alle RSS Feeds ➔
👥 Community & Social
Sichere ProgrammierungWhat breaks when your paid shell scripts run on macOS bash 3.2(01.10.2026 um 01:06 Uhr)
••
Sichere ProgrammierungAgents are starting to call each other. Nobody gave them receipts.(01.10.2026 um 01:10 Uhr)
•
Sichere ProgrammierungWhat I learned trying to index public Telegram communities(01.10.2026 um 01:17 Uhr)
•••••
Sichere ProgrammierungJoin Us Live: Hacktoberfest 2026 Launch with Exclusive Swag! 🎃🚀(01.10.2026 um 01:21 Uhr)
••
Sichere ProgrammierungWhat breaks when your paid shell scripts run on macOS bash 3.2(01.10.2026 um 01:06 Uhr)
••
Sichere ProgrammierungAgents are starting to call each other. Nobody gave them receipts.(01.10.2026 um 01:10 Uhr)
•
Sichere ProgrammierungWhat I learned trying to index public Telegram communities(01.10.2026 um 01:17 Uhr)
•••••
Sichere ProgrammierungJoin Us Live: Hacktoberfest 2026 Launch with Exclusive Swag! 🎃🚀(01.10.2026 um 01:21 Uhr)
••
Intelligence View
⚡ tsecurity.de Intelligence

Getting Started with Toge DB, A Javascript Based Database + ORM Layer

Intro Welcome to my article! I’d like to share a mini-project I built with the help of an AI coding assistant. Honestly, my initial goal was simply to learn h…

Beitrag
0
Seite
0
↗ Quelle (dev.to)
Social ReaktionenReagiere als Erste:r — dein Feedback zählt!




Intro



Welcome to my article! I’d like to share a mini-project I built with the help of an AI coding assistant.



Honestly, my initial goal was simply to learn how to use AI to boost my productivity, rather than creating something for public release. However, I believe this library is useful for those looking to build offline or online prototypes quickly using a JavaScript-based tech stack.



This database was built using 100% JavaScript and features an ORM layer that makes it easy to operate. In this article, I’ll show you how to build a simple Electron app using Toge DB.






1. Setup Electron App



If you are new to Electron development, you can refer to this official documentation for a deeper dive.



First, initialize an npm project and install the Electron dependency (please ensure the type value is set to module in your package.json):




mkdir toge-electron-app && cd toge-electron-app
npm init
npm install electron --save-dev






Next, open package.json and add "start": "electron ." to the scripts field:




{
"name": "toge-electron-app",
"version": "1.0.0",
"description": "",
"license": "ISC",
"author": "",
"type": "module",
"main": "index.js",
"scripts": {
"start": "electron .",
"test": "echo \"Error: no test specified\" && exit 1"
},
"devDependencies": {
"electron": "^40.0.0"
}
}






Create an index.js file and add the following console.log() script. Then, launch the app using the npm run start command:




console.log('Hello from Electron 👋')






Below is the expected result after running the command 🎉:








2. Setup Toge DB



To install Toge DB, execute the following command in your terminal:




npm install toge-db






Once the installation is complete, create a new .env file in the root of your Electron project and add the following configuration:




TOGE_DB_ADMIN_USER=your-username #fill with your desired username
TOGE_DB_ADMIN_PASSWORD=your-password #fill with your desired password






You can now access the Toge DB CLI using the command below. Log in using the credentials you just created:




npx toge-db






The result:





3. Create New Table and Populate Data



We need to create a table named fruit to store fruit names and their prices. Execute the following query to create the table:




CREATE TABLE fruit (name string PRIMARY KEY, price int)






Next, populate the table with some initial data. Please execute these queries one by one:




INSERT INTO fruit VALUES ('Banana', 5)
INSERT INTO fruit VALUES ('Apple', 10)
INSERT INTO fruit VALUES ('Orange', 8)






Finally, let's retrieve the data using the query below:




SELECT * FROM fruit






The Result:





4. Toge DB + Electron



As mentioned earlier, this database comes with a built-in ORM layer, allowing you to access your data quickly within your JavaScript application. Follow the instructions below to implement the ORM in your new Electron app.



To start using the ORM, import the TogeORM in your index.js file:




import { TogeORM } from 'toge-db';
const orm = new TogeORM('./data');

console.log('Hello from Electron 👋');






Next, we need to define the fruit Model to map the fruits name and their price. Use orm.define(modelName, schema) to create the Model.




const Fruit = orm.define('fruit', {
name: { type: 'string', primaryKey: true },
price: { type: 'int' }
});






Now, time to show all the fruits! Use Model.find(condition) to get the data. Add the example code below and then run npm run start.




console.log('Hello from Electron 👋');

// Find all fruits
const allFruits = Fruit.find();
allFruits.forEach(fruit => console.log("name: " + fruit.name + " price: " + fruit.price));






Congratulations! You have successfully integrated Toge DB into your Electron app 🎉:





For a complete CRUD implementation, update your code with the following code:




console.log('Hello from Electron 👋');

const newFruit = new Fruit({
name: 'Mango',
price: 100
});
newFruit.save();

Fruit.update(fruit => fruit.name === 'Banana', { price: 90 });
Fruit.delete(fruit => fruit.name === 'Orange');

const allFruits = Fruit.find();
allFruits.forEach(fruit => console.log("name: " + fruit.name + " price: " + fruit.price));






The Result:








Outro



Toge DB is still in active development. In the next version, I plan to add features such as indexing and additional query clauses like JOIN and LIKE. Please stay tuned for the new release! (https://www.npmjs.com/package/toge-db)



Thank you for reading! ^^

2. Cyber Threat Intelligence & Forensik

CTI Threat Relationship Graph2 Knoten / 1 Relationen
CVE / Incident Software MITRE ATT&CK CWE Weakness IoC
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Getting Started with Toge DB, A Javascript Based Database + ORM Layer

Thematisch verwandte Begriffe: Getting, Started, with, Toge · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

💬 Kommentare werden geladen…
Zum Aktualisieren ziehen
tsecurity.de Icon
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag