UNPKG

coders.db

Version:

A better sqlite3 system that is easy to install and easy to use, easy to config, non-locking. Made in coders code (https://discord.gg/cxJbCaqBPu)

17 lines (13 loc) 405 B
const get = require("lodash.get"); module.exports = function(db, params, options) { let fetched = db .prepare(`SELECT * FROM ${options.table} WHERE ID = (?)`) .get(params.id); if (!fetched) return null; fetched = JSON.parse(fetched.json); try { fetched = JSON.parse(fetched); } catch (e) {} if (params.ops.target) fetched = get(fetched, params.ops.target); return fetched; };