2.0.0 • Published 3 years ago

rammy-db v2.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years 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

3 years ago

1.0.12

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago