Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

prisma.db json

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


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: {} */
Comment

PREVIOUS NEXT
Code Example
Javascript :: convert h2 to h1 jQuery 
Javascript :: Priority Queue Element 
Javascript :: restart my react -Dom 
Javascript :: ajax fail function parameters 
Javascript :: django ajax json data become string 
Javascript :: nodejs split array into chunks 
Javascript :: check if a number is multiple of 3 javascript 
Javascript :: capitalize last letter javascript 
Javascript :: difference between usecallback and usememo 
Javascript :: updating a random variable in a function 
Javascript :: tool to show the date of page publish 
Javascript :: javascript split string into groups of n 
Javascript :: highcharts hide gaps 
Javascript :: tempusdominus calendar out of background size 
Javascript :: mongodb-nodejs-driver-deprecationwarning-collection-count-is-deprecated 
Javascript :: useMediaquery hook react 
Javascript :: utm to lat long 
Javascript :: copy array using spread operator 
Javascript :: get number value from input e.target.value instead of string 
Javascript :: React Router rendering blank pages for all components 
Javascript :: add flag persmison to write file nodejs 
Javascript :: angularjs Prevent from getting rendered 
Javascript :: AngularJS Pagination not showing all pages 
Javascript :: How to query a button with specific text with react native testing library 
Javascript :: change useragent cypress test run 
Javascript :: get the character code in a string 
Javascript :: C# Convert Json File to DataTable using Newtonsoft.Json DLL 
Javascript :: mustache tutorial javascript 
Javascript :: Uncaught Error: spawn node 
Javascript :: Jquery JavaScript Prevent From Press Enter Key Keyboard 
ADD CONTENT
Topic
Content
Source link
Name
3+6 =