Hello everyone! Repl.it just announced a new way to host your databases. They have created their own database type. It's unlike any other SQL/noSQL database: It is JSON based!!!
So, with help from @masfrost, I have created an npm package for it! It contains the native curl functions, and includes more (like emptying database, setting automatic types for values and more!) Also along the way, I learned testing with jest... Also, I got the hacker plan!
Without further ado, here are the docs!
1) Click on the floppy disk:
This is the homepage for your database. You can view storage usage and amount of keys.
2) Click on the box icon:
Install replitdb-client.
3) Copy and paste this code into the editor (if all you want is a minimalistic template).
4) Now, you are ready to set some commands! Inside the async function, you can do some methods. For our tutorial, we will make a what do you think of the node.js engine survey.
Some quick docs
Setting data
await client.set("<key>", "<value>")
getting data
await client.get("<key>", { raw: true|false })
you can leave out the raw part, but if you set raw to false, you will either get an object, or an error (the data wasn't valid json) listing keys
await client.list("<optional beginsWith>")
getting all data as an object
await client.getAll()
delete data
await client.delete("<key>")
delete all data
await client.empty()
Easy, right?
5) Prompt
Add this to your code:
const readline = require("readline");
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
rl.question("What do you think of node.js? ", async ans => {
rl.question("What is your name? ", async name => {
// TODO: Save to database
})
})
This just gets our form ready. Remember the async because we are using await calls here.
6) Save to database
Quite easy. We just refer to our set method in the docs.
const Client = require("replitdb-client");
const client = new Client();
const readline = require("readline");
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
rl.question("What do you think of node.js? ", async ans => {
rl.question("What is your name? ", async name => {
// Save
await client.set(name, ans);
})
})
7) Get all data
Now, we can use client.getAll to accomplish this!
const Client = require("replitdb-client");
const client = new Client();
const readline = require("readline");
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
rl.question("What do you think of node.js? ", async ans => {
rl.question("What is your name? ", async name => {
// Save
await client.set(name, ans);
console.log("Thank you for your valuable input!");
console.log("Previous users have said:");
// Get all data
let data = await client.getAll();
})
})
8) Parse the data
Right now our data is just an object, let's make it human-readable!
const Client = require("replitdb-client");
const client = new Client();
const readline = require("readline");
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
rl.question("What do you think of node.js? ", async ans => {
rl.question("What is your name? ", async name => {
// Save
await client.set(name, ans);
console.log("Thank you for your valuable input!");
console.log("Previous users have said:");
// Get all data
let data = await client.getAll();
for (const user in data) {
console.log(user, "has said", data[user]);
}
})
})
9) And that's it! We have gone through almost all of what you will be using for a database (with delete as an exception). I can't wait to see what you will make with the client!
Repl.it DB
Example test run for repl.it db
Working Form
Turn on explorer mode to use it!
Repl.it DB
Hello everyone! Repl.it just announced a new way to host your databases. They have created their own database type. It's unlike any other SQL/noSQL database: It is JSON based!!!
Links
Test run
Client code
NPM package
Github Code
Working "What do you think of node.js?" REPL
Node.js TUTORIAL
So, with help from @masfrost, I have created an npm package for it! It contains the native

curl
functions, and includes more (like emptying database, setting automatic types for values and more!) Also along the way, I learned testing with jest...Also, I got the hacker plan!
Without further ado, here are the docs!
1) Click on the floppy disk:
This is the homepage for your database. You can view storage usage and amount of keys.
2) Click on the box icon:
Install
replitdb-client
.3) Copy and paste this code into the editor (if all you want is a minimalistic template).
4) Now, you are ready to set some commands! Inside the
async
function, you can do some methods. For our tutorial, we will make awhat do you think of the node.js engine
survey.Some quick docs
Setting data
getting data
you can leave out the
raw
part, but if you setraw
to false, you will either get an object, or an error (the data wasn't valid json)listing keys
getting all data as an object
delete data
delete all data
Easy, right?
5) Prompt
Add this to your code:
This just gets our form ready. Remember the
async
because we are usingawait
calls here.6) Save to database
Quite easy. We just refer to our
set
method in the docs.7) Get all data
Now, we can use
client.getAll
to accomplish this!8) Parse the data
Right now our data is just an object, let's make it human-readable!
9) And that's it! We have gone through almost all of what you will be using for a database (with delete as an exception). I can't wait to see what you will make with the client!
Also, here's the working code for you to hack ;)
Homework
db.get
)Have a great day!
Ask in the comments below if you have any questions ;)
yay @Highwayman