How to use the node-json-db function in node-json-db

To help you get started, we’ve selected a few node-json-db examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zulip / zulip-desktop / app / renderer / js / utils / domain-util.ts View on Github external
const file = fs.readFileSync(domainJsonPath, 'utf8');
			JSON.parse(file);
		} catch (err) {
			if (fs.existsSync(domainJsonPath)) {
				fs.unlinkSync(domainJsonPath);
				dialog.showErrorBox(
					'Error saving new organization',
					'There seems to be error while saving new organization, ' +
					'you may have to re-add your previous organizations back.'
				);
				logger.error('Error while JSON parsing domain.json: ');
				logger.error(err);
				logger.reportSentry(err);
			}
		}
		this.db = new JsonDB(domainJsonPath, true, true);
	}
github zulip / zulip-desktop / app / renderer / js / utils / certificate-util.ts View on Github external
const settingsJsonPath = path.join(app.getPath('userData'), '/config/certificates.json');
		try {
			const file = fs.readFileSync(settingsJsonPath, 'utf8');
			JSON.parse(file);
		} catch (err) {
			if (fs.existsSync(settingsJsonPath)) {
				fs.unlinkSync(settingsJsonPath);
				dialog.showErrorBox(
					'Error saving settings',
					'We encountered error while saving the certificate.'
				);
				logger.error('Error while JSON parsing certificates.json: ');
				logger.error(err);
			}
		}
		this.db = new JsonDB(settingsJsonPath, true, true);
	}
}
github zulip / zulip-desktop / app / renderer / js / utils / config-util.ts View on Github external
try {
			const file = fs.readFileSync(settingsJsonPath, 'utf8');
			JSON.parse(file);
		} catch (err) {
			if (fs.existsSync(settingsJsonPath)) {
				fs.unlinkSync(settingsJsonPath);
				dialog.showErrorBox(
					'Error saving settings',
					'We encountered an error while saving the settings.'
				);
				logger.error('Error while JSON parsing settings.json: ');
				logger.error(err);
				logger.reportSentry(err);
			}
		}
		this.db = new JsonDB(settingsJsonPath, true, true);
	}
}
github zulip / zulip-desktop / app / renderer / js / utils / linux-update-util.ts View on Github external
const linuxUpdateJsonPath = path.join(app.getPath('userData'), '/config/updates.json');
		try {
			const file = fs.readFileSync(linuxUpdateJsonPath, 'utf8');
			JSON.parse(file);
		} catch (err) {
			if (fs.existsSync(linuxUpdateJsonPath)) {
				fs.unlinkSync(linuxUpdateJsonPath);
				dialog.showErrorBox(
					'Error saving update notifications.',
					'We encountered an error while saving the update notifications.'
				);
				logger.error('Error while JSON parsing updates.json: ');
				logger.error(err);
			}
		}
		this.db = new JsonDB(linuxUpdateJsonPath, true, true);
	}
}
github yamdbf / core / src / lib / storage / LocalStorage.js View on Github external
constructor(fileName)
	{
		if (!fileName) throw new Error('You must provide a file name for the LocalStorage');

		/** @type {Object} */
		this._db = new Database(fileName, true, true);

		/** @type {Object} */
		this._temp = {};
	}

node-json-db

Database using JSON file as storage for Node.JS

MIT
Latest version published 1 year ago

Package Health Score

61 / 100
Full package analysis