Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

prisma.db yaml

const { YamlDatabase } = require("prisma.db");
const db = new YamlDatabase({ dbPath: "./db.yaml" });

db.set("hello", "world"); /* String: World */
db.set("posts", [{ id: 1 }]); /* Array: [{ id: 1 }] */
db.push("posts", { id: 2 }); /* Array: [{ id: 1 }, { id: 2 }] */

db.fetch("hello"); /* String: World */
db.get("posts"); /* Array: [{ id: 1 }, { id: 2 }] */
db.has("posts"); /* Boolean: true */
db.dataAll(); /* Object: { hello: "World", posts: [{ id: 1 }, { id: 2 }] } */

db.set("a", 1);
db.add("a", 1); /* Number: 2 */
db.subtract("a", 1); /* Number: 1 */
db.math("a", "+", 12); /* Number: 13 */
db.math("a", "-", "1"); /* Number: 12 */
db.math("a", "*", "2"); /* Number: 24 */
db.math("a", "/", "2"); /* Number: 12 */
db.math("a", "%", "5"); /* Number: 1 */

db.type("hello"); /* String: "string" */
db.size(); /* Number: 1 */

db.delete("hello"); // returns true
db.clear(); /* Object: {} */
db.destroy(); /* Object: {} */
 
PREVIOUS NEXT
Tagged: #yaml
ADD COMMENT
Topic
Name
5+4 =