{"id":27392205,"url":"https://github.com/samt/node-dbx","last_synced_at":"2025-10-09T09:14:33.541Z","repository":{"id":148539154,"uuid":"41984894","full_name":"samt/node-dbx","owner":"samt","description":"ORM DB access for SQL backends","archived":false,"fork":false,"pushed_at":"2015-09-07T17:41:59.000Z","size":136,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-10-09T09:14:19.878Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/samt.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-09-06T03:08:34.000Z","updated_at":"2015-09-06T03:51:53.000Z","dependencies_parsed_at":"2023-04-07T04:55:12.422Z","dependency_job_id":null,"html_url":"https://github.com/samt/node-dbx","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/samt/node-dbx","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samt%2Fnode-dbx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samt%2Fnode-dbx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samt%2Fnode-dbx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samt%2Fnode-dbx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/samt","download_url":"https://codeload.github.com/samt/node-dbx/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samt%2Fnode-dbx/sbom","scorecard":{"id":798187,"data":{"date":"2025-08-11","repo":{"name":"github.com/samt/node-dbx","commit":"60cd94d8b673ceea2e4103d196cbe99d72d25e98"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.6,"checks":[{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Code-Review","score":0,"reason":"Found 0/6 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-23T09:37:38.944Z","repository_id":148539154,"created_at":"2025-08-23T09:37:38.944Z","updated_at":"2025-08-23T09:37:38.944Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279001114,"owners_count":26083021,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-04-13T21:18:17.195Z","updated_at":"2025-10-09T09:14:33.525Z","avatar_url":"https://github.com/samt.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dbx\n\nEvent-driven, agnostic, sane ORM for the rest of us.\n\n**Please Note: This is still a WIP and does not contain working code as of yet**\n\n## What is dbx?\n\nThis is really just a dispatcher that sends everything around, making your database more event-driven. It abstracts away the database making a SQL system resemble more of a document-based store. It has some small opinions about the final schema, but they can be overridden. This system also enables the use of caching engines to squeeze better performance out of your fetch operations.\n\n## Concepts\n\n### DB agnostic\n\nWhile this is modeled around the constraints of a [RDBMS](https://en.wikipedia.org/wiki/Relational_database_management_system), it is entirely possible to use it for any sort of data store, you just have to write the driver for it. Types are abstracted to be very granular and can easily be implemented with polyfills.\n\n### Hookable\n\nNo need for janky workarounds, you have access to the data at every step pre and post processing to do additional validation, model validation, or whatever you wish. It will be easier to pick up if you all you know is running SQL against a database.\n\n### Only as much magic as you want\n\nIn the [Defining Models](#Defining-Models) section, we go through the items that are created automatically for you, but can be easily enabled or disabled at the local, Model Level, or at the global Application Level. Field names are not changed for you on the DB's side, making custom queries easy to work with.\n\n### Support for caching engines\n\nHitting the DB is expensive, you can enable caching engines and tweak any setting.\n\n### Strict conventions\n\n* Dates are stored as unix timestamps\n* The first `err` parameter will either be an instance of `dbx.Error` or Boolean `false` if no error happened. No null, no undefined, just a normal false (See [The Worst Mistake of Computer Science](https://www.lucidchart.com/techblog/2015/08/31/the-worst-mistake-of-computer-science/)).\n\n# \u003ca name=\"Install\"\u003e\u003c/a\u003e Install\n\n\tnpm install dbx --save\n\n# \u003ca name=\"Usage\"\u003e\u003c/a\u003e Usage\n\n## Connections\n\n### Basic\n```js\n// contains all the classes\nvar dbx = require('dbx');\n\n// create a new connection\nvar db = new dbx.Connection({\n\tdriver: require('dbx-mysql'),\n\tdbuser: 'root',\n\tdbpass: 'passw0rd',\n\tdbname: 'mydb'\n});\n\n// define caching options (Todo)\ndb.cache();\n\n// connect!\ndb.connect(function (err) {\n\tconsole.log('connected!');\n});\n```\n\n### Getting a previously established connection\n\nYou might also want to use this connection in another file where db might not necessarily be in scope. You can use the singleton getter to accomplish just that:\n\n```js\nvar dbx = require('dbx');\nvar db = dbx.Connection.get();\n```\n\n### Multiple connections\n\nConnecting to multiple servers? not to worry, you can name your connection:\n\n```js\nvar anotherDb = new dbx.Connection('myservice', {\n\tdriver: require('dbx-mysql'),\n\thost: '10.23.44.44',\n\tport: 64324\n\tdbuser: 'root',\n\tdbpass: 'passw0rd',\n\tdbname: 'myservicedb'\n});\n\nanotherDb.connect(function (err) {\n\tconsole.log('connected!')\n});\n```\n\nGetting the connection back in other files is just as easy:\n\n```js\nvar dbx = requre('dbx');\nvar db = dbx.Connection.get(); // get the main connection\nvar anotherDb = dbx.Connection.get('myservice'); // get a named connection!\n```\n\n## \u003ca name=\"Defining-Models\"\u003e\u003c/a\u003e Defining Models\n\nModels are nothing more than a representation of a table that they owe their namesake to. We abstract types here to very high-level ones, but you may also use the lower level ones if it suites your needs better.\n\n```js\n// 'db' is a connected database object\nvar User = db.define('User', {\n\tname: { type: 'string' },\n\temail: { type: 'string', key: 'unique' },\n\tpassword: { type: 'string' },\n\ttype: { type: 'flag', key: 'index', values: { '0': 'Normal', '1': 'Admin' } },\n\tdateLastLogin: { type: 'timestamp' },\n\tsocial: { type: 'json' },\n\tbio: { type: 'text' }\n});\n\nvar Post = db.define('Post', {\n\tauthorId: { type: 'fk', model: 'User', field: 'id' },\n\tisVisible: { type 'boolean' },\n\ttitle: { type: 'string' },\n\tbody: { type: 'text' }\n});\n\n// Using shorthand types\nvar Comment = db.define('Comment', {\n\tpostId: 'fk.Post.id',\n\tauthorId: 'fk.User.id',\n\tbody: 'text',\n});\n```\n\nA few things are going on here:\n\n* Passing in the first parameter (string \"User\", in the user-model's case) gives you both a way to fetch the model later, but it also identifies the table name in the database.\n* The second parameter is a key/value object that contains field information, with the field's name being key. It is advisable to keep the field names valid JS identifiers for simplicity, however they can be any quoted string.\n* An auto-incrementing \"id\" filed was omitted, it is given to you by default.\n* Most date fields are absent. `dateCreated` and `dateUpdated` are given to you by default.\n* Shorthand notation is used in the Comment model, where you simply define the type instead of a field object.\n\n### \u003ca name=\"Field-Types\"\u003e\u003c/a\u003e Field types\n\n* `type`: **(Required)** Field type, use one of the following:\n    * `id`: Auto-incrementing ID, unsigned. Indexed (as Primary Key) automatically.\n    * `fk`, `fk.TABLE.FIELD`: foreign key, same as ID except not auto-incrementing. Indexed automatically.\n    * `int`: Signed, 8bit int, -2147483648 to 2147483647\n    * `uint`: Unsigned, 8bit int, 0 to 4294967295\n    * `flag`: Integer ranging from -128 to 127, typically a signed 8bit int. Indexed automatically.\n    * `timestamp`: For unix timestamps, typically `uint`. Can only represent dates from Jan 1st 1970 00:00:00 to Feb 7th 2106 06:28:15 UTC.\n    * `string`: Single-line string, no bigger than 255 bytes (UTF-8 warning! 1 byte is not always 1 char)\n    * `char`, `char.X`: Byte of maximum `X` length. Do not use for any UGC as per the UTF-8 warning.\n    * `text`: Block of text no bigger than 65,535 bytes (See UTF-8 warning above)\n    * `json`: Same basic type as `text`, but converted to and from JSON automatically by the model\n* `size`: **(Optional)** Only honored on fields that accept field size: (`char`, `string`)\n* `def`: **(Optional)** Default value for the field.\n    * Default: `''` or `0` depending on field type\n* `notnull`: **(Optional)** Does this field require some data in it?\n    * Default: true\n* `key`: **(Optional)** Can be `primary`, `unique`, `index`, `text`. Note that `primary` cannot be used if you're using the `id` field, built-into models by default.\n    * Default: Depends on `type`\n* `values`: **(Optional)** Useful for the `flag` type only. Key/value Object (with quoted numbers as keys) containing possible values.\n* `model`: **(Optional)** Useful for the `fk` type only. May use the foreign key shorthand instead.\n* `field`: **(Optional)** Useful for the `fk` type only. May use the foreign key shorthand instead.\n\n## Inserting records\n\n```js\nvar User = db.model('User');\n\nUser.create({\n\t'name': 'John Doe',\n\t'email': 'john@doe.com',\n\t'password': 'hunter2'\n}, function (err, record) {\n\tif (err) throw err;\n\n\tconsole.log('User exists:', record.exists);\n\tconsole.log(record.name + ' \u003c' + record.email + '\u003e');\n});\n```\n\n## Get a record by ID\n\n```js\nvar User = db.model('User');\n\nUser.get(5, function (err, user) {\n\tconsole.log('Hello, ' + user.name);\n});\n```\n\n## Save a record\n\n```js\nvar User = db.model('User');\n\nUser.get(5, function (err, user) {\n\tuser.email = 'john.doe@gmail.com';\n\n\tuser.save(function (err) {\n\t\tif (err) throw err;\n\t\tconsole.log('New email saved!');\n\t});\n});\n```\n\n## Delete a record\n\n```js\nvar User = db.model('User');\n\nUser.get(5, function (err, user) {\n\tuser.delete(function (err) {\n\t\tif (err) throw err;\n\t\tconsole.log('User exists? ', user.exists);\n\t});\n});\n```\n\n## Using events\n\nIn the previous `User.create` example, you can see the password is sent to the database with what looks like pain text. We can use an event hook for the User model to transform the password into a hashed version of whatever the password is.\n\n```js\nvar bcrypt = require('bcryptjs');\nUser.on('preSave', function (record, callback) {\n\t// preSave is NOT a validation hook, it may be possible that we do have/want\n\t// a password to update an incoming record with.\n\tif (!record.password.length) {\n\t\treturn callback();\n\t}\n\n\tbcrypt.hash(record.password, function (err, hashed) {\n\t\tif (err) return callback(err);\n\n\t\trecord.password = hashed;\n\t\treturn callback();\n\t});\n});\n```\n\n# API\n\n**The API is still a WIP and should be considered VOLATILE. It is not to be relied upon until the first major release.**\n\n## \u003ca name=\"dbx.Connection\"\u003e\u003c/a\u003e Class: dbx.Connection\n\nConstructor to create a new connection, defines the database driver and other driver-specific options.  See [Database Drivers](#) for more information.\n\n\tdbx.Connection([identifier], options)\n\n* `identifier` - 'String' (optional): Omit to have returned the default connection\n* `options` - 'Object': With the following options:\n\t* `driver` - Driver implementing `dbx`, use `require('dbx-mysql')` for mysql\n\t* `host` - Hostname to connect to\n\t* `port` - Port to connect to\n\t* `dbname` - Name of DB\n\t* `dbuser` - Username to connect to DB with\n\t* `dbpass` - password to authenticate the user with\n\nThis is an [`EventEmitter`](https://nodejs.org/api/events.html#events_class_events_eventemitter) with the following events:\n\n### Event: 'connection'\n\nEmitted upon successful connection\n\n\tfunction (err, connection) { }\n\n* `err` instance of [`dbx.Error`](#dbx.Error), `false` otherwise\n\n### Event: 'disconnect'\n\nEmitted upon disconnect.\n\n\tfunction (err, reason) { }\n\n* `err` instance of [`dbx.Error`](#dbx.Error), `false` otherwise\n* `reason` int (enum)\n\n### Event: 'error'\n\nEmitted each time an error occurs.\n\n\tfunction (err) { }\n\n* `err` instance of [`dbx.Error`](#dbx.Error)\n\n### Event: 'query'\n\nEmitted when a query is ran\n\n\tfunction (err, query)\n\n* `err` instance of [`dbx.Error`](#dbx.Error), `false` otherwise\n* `query` instance of [`dbx.Query`](#dbx.Query)\n\n### Connection.get([identifier])\n\n(Static access) get the connection\n\n* `identifier` string\n\nReturns instance of [dbx.Connection](#dbx.Connection).\n\n### connection.isConnected\n\nBoolean - returns the state of the connection\n\n### connection.hasError\n\nBoolean - returns whether or not a connection-level error has occurred.\n\n### connection.lastError\n\nString - Information about the last connection-level error\n\n### connection.cache(options)\n\nDefine a caching engine. See [Caching Engines](#).\n\n### connection.connect([callback])\n\nConnect to the DB server\n\n* `callback` function\n\n### connection.define(name, options)\n\nDefine a new model. See [Defining Models](#Defining-Models).\n\n* `name` String - Name of the model\n* `options` Object - Object containing the model definition\n\nReturns an instance of [dbx.Model](#dbx.Model).\n\n### connection.model(name)\n\nGet the model by its name.\n\n* `name` String - Name of the model defined previously\n\nReturns an instance of [dbx.Model](#dbx.Model).\n\n### connection.query(name, [fromCache, ] callback)\n\nDirectly run an SQL query.\n\n* `sql` string\n* `fromCache` boolean (optional) attempt to load from cache\n* `callback` callback function accepting the following parameters\n\t* `err` instance of [`dbx.Error`](#dbx.Error) if error, `false` otherwise\n\t* `records`\tArray, instances of [`dbx.Record`](#dbx.Record)\n\n## \u003ca name=\"dbx.Model\"\u003e\u003c/a\u003e Class: dbx.Model\n\nThe base class for all data models. Note that this is *only* the API documentation, for a more practical introduction to models, see [Defining Models](#Defining-Models). Note that it cannot be used directly, rather only through defining a model, which will have an instance returned to you. The consequence of this is that all events listed here are local to individual models.\n\nThis is an [`EventEmitter`](https://nodejs.org/api/events.html#events_class_events_eventemitter) with the following events:\n\n### Event: 'postCreate'\n\nEmitted after a successful write is issued for a new record.\n\n\tfunction (record, [callback]) { }\n\n* `record` instance of [`dbx.Record`](#dbx.Record)\n* `callback` callback function accepting no parameters\n\n### Event: 'postDelete'\n\nEmitted after a successful delete has been issued.\n\nSee Event 'postCreate' for callback details\n\n### Event: 'postFetch'\n\nEmitted after a fetch operation is issued to the DB.\n\n\tfunction (query, [callback]) { }\n\n* `query` instance of [`dbx.Query`](#dbx.Query)\n* `records` Array of [`dbx.Record`](#dbx.Record)\n* `callback` callback function accepting no parameters\n\n### Event: 'postSave'\n\nEmitted after a successful write is issued for either a new or an existing record.\n\nSee Event 'postCreate' for callback details\n\n### Event: 'postUpdate'\n\nEmitted after a successful write is issued for an existing record.\n\nSee Event 'postCreate' for callback details\n\n### Event: 'preCreate'\n\nEmitted before a write is issued for a new record. Use this hook for formatting data or injecting data into the query before it's run. use the 'validate' event for data validation.\n\n\tfunction (record, [callback]) { }\n\n* `record` instance of [`dbx.Record`](#dbx.Record)\n* `callback` callback function accepting the following parameters:\n\t* `err` instance of [`dbx.Error`](#dbx.Error) if error, false otherwise. Errors will abort the write and it will bubble up\n\n### Event: 'preDelete'\n\nEmitted before a delete is issued to an existing record.\n\n\tfunction (record, [callback]) { }\n\n* `record` instance of [`dbx.Record`](#dbx.Record)\n* `callback` callback function accepting the following parameters:\n\t* `err` instance of [`dbx.Error`](#dbx.Error) if error, false otherwise. Errors will abort the delete and it will bubble up\n\n### Event: 'preFetch'\n\nEmitted before a fetch operation is issued to the DB\n\n\tfunction (query, [callback]) { }\n\n* `query` instance of [`dbx.Query`](#dbx.Query)\n* `callback` callback function accepting the following parameters:\n\t* `err` instance of [`dbx.Error`](#dbx.Error) if error, false otherwise. Errors will abort the delete and it will bubble up\n\n### Event: 'preSave'\n\nEmitted before a write is issued for either a new or an existing record.\n\nSee Event 'preCreate' for callback details\n\n### Event: 'preUpdate'\n\nEmitted before a write is issued for an existing record.\n\nSee Event 'preCreate' for callback details\n\n### Event: 'validate'\n\nEmitted before any db operations have taken place, this is where you can validate information and error out if needed.\n\n\tfunction (record, [callback]) { }\n\n* `record` instance of [`dbx.Record`](#dbx.Record)\n* `callback` callback function accepting the following parameters\n\t* `err` instance of [`dbx.Error`](#dbx.Error) if error, false otherwise. Errors will abort the write and it will bubble up\n\n### model.name\n\nString - name the model is identified by\n\n### model.fields\n\nObject - Key/value pairs containing the fields that this model can have.\n\n### model.count(query, callback)\n\nCount the number of records in a query.\n\n* `query` instance of [`dbx.Query`](#dbx.Query)\n* `callback` callback function accepting the following parameters\n\t* `err` instance of [`dbx.Error`](#dbx.Error) if error, false otherwise\n\t* `count` Number\n\n### model.create(obj, callback)\n\nCreate a new record, does not issue a create in the DB yet.\n\n* `obj` key/value hash of fields OR instance of [`dbx.Record`](#dbx.Record) (to clone an object)\n* `callback` callback function accepting the following parameters\n\t* `err` instance of [`dbx.Error`](#dbx.Error) if error, false otherwise\n\t* `record` instance of [`dbx.Record`](#dbx.Record)\n\n### model.get(id, [fromCache], callback)\n\nFetch one by the primary key.\n\n* `id` primary key identifier as defined in the model\n* `fromCache` boolean (optional) attempt to load from cache\n* `callback` callback function accepting the following parameters\n\t* `err` instance of [`dbx.Error`](#dbx.Error) if error, false otherwise\n\t* `record` instance of [`dbx.Record`](#dbx.Record)\n\n### model.getAll(ids, [fromCache], callback)\n\nFetch many by an array of primary keys.\n\n* `ids` Array of primary key identifier as defined in the model\n* `fromCache` boolean (optional) attempt to load from cache\n* `callback` callback function accepting the following parameters\n\t* `err` instance of [`dbx.Error`](#dbx.Error) if error, false otherwise\n\t* `records`\tArray, instances of [`dbx.Record`](#dbx.Record)\n\n### model.search(query, [fromCache], callback)\n\nPerform a search on a model.\n\n* `query` instance of [`dbx.Query`](#dbx.Query)\n* `fromCache` boolean (optional) attempt to load from cache\n* `callback` callback function accepting the following parameters\n\t* `err` instance of [`dbx.Error`](#dbx.Error) if error, false otherwise\n\t* `records`\tArray, instances of [`dbx.Record`](#dbx.Record)\n\n### model.query(sql, [fromCache], callback)\n\nAlias of `connection.query()`\n\n## \u003ca name=\"dbx.Record\"\u003e\u003c/a\u003e Class: dbx.Record\n\n### record.delete([callback])\n\nDelete the instance record.\n\n* `callback` callback function accepting the following parameters\n\t* `err` instance of [`dbx.Error`](#dbx.Error) if error, false otherwise\n\n### record.save([callback])\n\nSaves the current state of the model (updates or creates).\n\n* `callback` callback function accepting the following parameters\n\t* `err` instance of [`dbx.Error`](#dbx.Error) if error, false otherwise\n\n### record.dateCreated\n\nNumber - Unix timestamp from when the record was originally created\n\n### record.dateModified\n\nNumber - Unix timestamp from when the record was last updated\n\n### record.exists\n\nBoolean - Whether the record exists in the DB or not\n\n### record.id\n\nNumber|String - Primary key of the record, falsey if this is not used as the main ID.\n\n### record.inCache\n\nBoolean - Whether the record exists in the cache or not. Always false if no caching engine is defined.\n\n## \u003ca name=\"dbx.Query\"\u003e\u003c/a\u003e Class: dbx.Query\n\n### query.executionTime\n\nNumber - Time in seconds\n\n### query.hasRun\n\nBoolean - Has the query been executed yet\n\n### query.inCache\n\nBoolean - Were the results in cache?\n\n### query.numResults\n\nNumber - Number of results\n\n### query.results\n\nArray - Raw results\n\n### query.sql\n\nString - raw SQL query\n\n## \u003ca name=\"dbx.Error\"\u003e\u003c/a\u003e Class: dbx.Error\n\n### Error.LEVELS\n\n(Static access) Array of valid error levels.\n\n### Error.TYPES\n\n(Static access) Array of valid error types\n\n### error.level\n\nNumber - see Error.LEVELS for possible values\n\n### error.type\n\nNumber - See Error.TYPES for possible values\n\n### error.message\n\nString - Message that is safe to surface to the end user\n\n### error.internalMessage\n\nString - Message with information about the error itself that is only meant to be viewed by an elevated user.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamt%2Fnode-dbx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsamt%2Fnode-dbx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamt%2Fnode-dbx/lists"}