2.0.0 • Published 1 year ago

rammy-db v2.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

RammyDB Text

RammyDB

Stores data in disk and ram synchronously.

Supports Custom Classes

Supports custom classes but only works if #toJSON() returns constructor argument.

Example

const { RamDB, toCustomClass } = require("rammy-db");
const path = require("path");

class Game { constructor(arg) { this.data = {}; for (let i in arg) { this.data[i] = arg[i] } }; toJSON() { return {...this.data} } }
class User { constructor(arg) { this.data = {}; for (let i in arg) { this.data[i] = arg[i] } }; toJSON() { return {...this.data} } }

const model = new RamDB({
	path: path.resolve(process.cwd(), "./data.json"),
	timeout: 5000,
	default: {
		/** @type {Game[]} */
		games: [],
		queueData: {
			/** @type {string[]} */
			players: [],
			size: 0
		},
		/** @type {User[]} */
		users: []
	},
	customClasses: [toCustomClass(User), toCustomClass(Game)]
});

module.exports = db;
2.0.0

1 year ago

1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago