Make ORMs great again!

Overview

OpenRecord

Build Status Coverage Status npm package version Package Quality Code Quality: Javascript Total Alerts

OPENRECORD is an ActiveRecord inspired ORM for nodejs.

Currently it supports the following databases/datastores: SQLite3, MySQL, Postgres, Oracle, REST and LDAP (+ ActiveDirectory)
If you want to build a GraphQL endpoint for any of these databases, OPENRECORD has some built in features to support you!

As the name imply, it's open and very easy to extend. The whole package was build that way.

It has a lot of features, just take a look at the docs!

Usage example

Here is an example how to get a single post from an existing sqlite3 file (by primary key).

const Store = require('openrecord/store/sqlite3')

const store = new Store({
  file: './my-posts-db.sqlite3',
  autoLoad: true
})

store.ready(async () => {
  const post = await store.Model('Post').find(1)
  console.log(post)
})

You don't have to define your model (optional) and you also don't have to define your model's attributes (optional).
Take a look at the docs to get started!

Contributing

If you've found a bug please report it via the issues page.
Before you submit a pull request, please make sure all tests still pass.


Sponsored by digitalbits.at

Comments
  • API reference needed

    API reference needed

    I spent a longtime hunting for a way to close my connection (using sqlite), it seems connection is not exposed to end user, so how can I exit an one-time migration script gracefully?

    (besides process.exit(0); which works, but it's ignoring the store connection)

    opened by bitinn 33
  • Model.create() should return the created instance

    Model.create() should return the created instance

    given the following code:

    Account.create({email: '[email protected]', password: 'password'}))
    .then(function(account){
      console.log(account) //true, should be {id: NEW_ID, email: ..., etc})
    })
    

    the returned account is true instead of the object that was created

    this will create race conditions if I need that newly created record as relying on 'last insert' is not thread safe. postgres has the option RETURNING in Insert calls. that should be used to return the id of the object at least

    opened by SampsonCrowley 15
  • `where` and `scope` on associations

    `where` and `scope` on associations

    Is it possible to do something like

    let user = await User.find(1);
    let posts = await user.posts.where({visible: true});
    

    where the user hasMany('posts').

    or maybe creating scopes on Post model and applying the scope to the relation instead of doing .where?

    opened by amir-s 14
  • select_value as in activerecord

    select_value as in activerecord

    ActiveRecord has useful methods select_value, select_values, select_rows and other.

    I'd like to use row_to_json from postres as it is the most efficient way to give result from API.

    I'd like to add some helper kind of this:

    class BaseModel extends require('openrecord/store/postgres').BaseModel {
      static jsonArrayString() {
        return this.select(`row_to_json(${this.tableName}.*)`).select_value()
      }
    }
    

    (don't sure yet how is static method could be integrated with OpenRecord models)

    And then use it like:

    const jsonString = User.where(conditions).select(fields).jsonArrayString()
    return jsonString to client
    

    Method select_value should take the first row the first column result without parsing and just return it.

    Maybe I could try to implement it and make PR, will it be useful, how do you think?

    By the way, OpenRecord looks the most convinient library among other ORMs for node.js, especially for RoR developers, thanks a lot

    opened by romeerez 12
  • Model.create({}) and Model.new({}) autoAttributes = true

    Model.create({}) and Model.new({}) autoAttributes = true

    Hey, i using autoAttributes = false andautoLoad = false, because i want to the more controls of my attributes, but the docs say const user = await User.create({login: 'philipp'}) but not work i think is pass null, here the error message:

    Error: insert into "users" default values - null value in column "login" violates not-null constraint

    will be nice if the project have some exemples the docs is great any way

    i thinks this is not the right place to put this issue, but i cant find anything on in the SO

    opened by claudioluciano 11
  • ID conversion problem

    ID conversion problem

    Hi! I use the String type for IDs in the sqlite3 database (because JavaScript does not support BIGINT). When use such code, get the wrong record.

    var res = await store.Model ('Guild'). find ("583946876706095100");
    console.log (res);
    

    <Guild {id: "411600256049086460" cmdPrefix: "+"}>

    Note that ID is different.

    If change the ID so that they begin NOT with a number (for example, "_583946876706095100"), then everything works as intended.

    I tried to add to the model

    static definition () {
       this.attribute ('id', String);
    }
    

    but that did not solve the problem.

    opened by idma88 9
  • Roadmap for v2

    Roadmap for v2

    It has been a while since the last major update of openrecord. The reason is, it's running in production for for almost 3 years without problems. And is has all the features that we needed.

    openrecord was originally written for node 0.10 and a lot has changed in the javascript world since then.

    Things I like to change/add for version 2.0 (v2 branch):

    • [ ] ~Use ES6 import/export~ use babel...
    • [x] async/await support
    • [ ] ~Add support for NoSQL stores (e.g. DynamoDB)~ => V2.1
    • [ ] ~Better support for transforming result data~ => V2.1
    • [x] more declarative model definition syntax
    • [ ] ~Browser support #28. e.g. with a thin wrapper over rxdb and the rest-store, combined with cross store relations.~ https://github.com/PhilWaldmann/openrecord/issues/28#issuecomment-372953160
    • [x] Graphql support
    • [x] Real docs!!
    • [x] ESLint (instead of jshint)
    • [x] remove async in favor of promises (https://github.com/PhilWaldmann/openrecord/issues/36#issuecomment-318508873)
    • [x] Oracle support (#53)
    • [ ] ~Cordova SQLite native support~ (https://github.com/PhilWaldmann/openrecord/issues/28#issuecomment-318719391) https://github.com/tgriesser/knex/issues/1845
    opened by PhilWaldmann 9
  • Help with Transaction, please

    Help with Transaction, please

    Hello, tried using transaction like:

    await new Promise(resolve => store.startTransaction(resolve))
      .then(trx => Promise.all(
        [Model1.useTransaction(trx).create({ valid: 12 }),
        Model2.useTransaction(trx).create({ invalid: 'a validation error' })]
      ))
    

    But the validation error on Model2 did not prevent Model1 record creation, so there was no rollback. Is transaction available or am i using it wrong?

    opened by arthurfranca 8
  • Fix UUID issue

    Fix UUID issue

    Fixed an issue where a default value regex test /-?\d+/ was matching against uuid_generate_v1() and uuid_generate_v4()

    added test to confirm null default on UUID default columns

    probably could still use a validation to confirm UUID but i don't think thats vital right now

    opened by SampsonCrowley 8
  • Can't get relations to work

    Can't get relations to work

    Hi! I'm just starting to use this package, but I need some help since the docs are not complete as stated in other issues. I'm getting a "Can't find relation" error. Here is my setup:

    // ClutchUsers.model.js
    module.exports = function ClutchUsers() {
      this.hasMany('clutch_user_permission')
          .hasMany('clutch_module', {through: 'clutch_user_permissions', primary_key: 'id', foreign_key: 'user'})
    
          .scope('active', function () {
            this.where({status: 1})
          })
    }
    
    // ClutchUserPermissions.model.js
    module.exports = function ClutchUserPermissions () {
      this.belongsToMany('clutch_user')
          .belongsToMany('clutch_module')
    }
    
    // ClutchModules.model.js
    module.export = function ClutchModules () {
      this.hasMany('clutch_user_permission')
          .hasMany('clutch_user', {through: 'clutch_user_permissions', primary_key: 'id', foreign_key: 'module'})
    }
    

    I tried following the examples but it is not working when I run something like this:

    store.ready(() => {
      const ClutchUsers = store.Model('ClutchUsers')
      ClutchUsers.active().include('clutch_modules').exec((records) => {
        console.log(records)
      })
    })
    

    For reference: table names are clutch_users, clutch_user_permissions, clutch_modules. Both users and modules have an id pk column, and the permissions table has user and module columns for each of them as fk.

    Without include it works, but I also want the modules that each user has. What am I doing wrong?

    Thank you and congratulations on this awesome package!

    opened by matheusgrieger 7
  • table name error

    table name error

    Thanks for a great library. there is a table(admin) in mysql, i use "store.Model('admin');". node js log error "Error: ER_NO_SUCH_TABLE: Table 'test.admins' doesn't exist"

    opened by xualen 6
  • Bump prismjs from 1.23.0 to 1.24.0

    Bump prismjs from 1.23.0 to 1.24.0

    Bumps prismjs from 1.23.0 to 1.24.0.

    Release notes

    Sourced from prismjs's releases.

    v1.24.0

    Release 1.24.0

    Changelog

    Sourced from prismjs's changelog.

    1.24.0 (2021-06-27)

    New components

    Updated components

    ... (truncated)

    Commits
    Maintainer changes

    This version was pushed to npm by rundevelopment, a new releaser for prismjs since your current version.


    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • Bump normalize-url from 4.5.0 to 4.5.1

    Bump normalize-url from 4.5.0 to 4.5.1

    Bumps normalize-url from 4.5.0 to 4.5.1.

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • Bump browserslist from 4.16.3 to 4.16.6

    Bump browserslist from 4.16.3 to 4.16.6

    Bumps browserslist from 4.16.3 to 4.16.6.

    Changelog

    Sourced from browserslist's changelog.

    4.16.6

    • Fixed npm-shrinkwrap.json support in --update-db (by Geoff Newman).

    4.16.5

    • Fixed unsafe RegExp (by Yeting Li).

    4.16.4

    • Fixed unsafe RegExp.
    • Added artifactory support to --update-db (by Ittai Baratz).
    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • Bump hosted-git-info from 2.8.8 to 2.8.9

    Bump hosted-git-info from 2.8.8 to 2.8.9

    Bumps hosted-git-info from 2.8.8 to 2.8.9.

    Changelog

    Sourced from hosted-git-info's changelog.

    2.8.9 (2021-04-07)

    Bug Fixes

    Commits
    Maintainer changes

    This version was pushed to npm by nlf, a new releaser for hosted-git-info since your current version.


    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • Bump lodash from 4.17.19 to 4.17.21

    Bump lodash from 4.17.19 to 4.17.21

    Bumps lodash from 4.17.19 to 4.17.21.

    Commits
    • f299b52 Bump to v4.17.21
    • c4847eb Improve performance of toNumber, trim and trimEnd on large input strings
    • 3469357 Prevent command injection through _.template's variable option
    • ded9bc6 Bump to v4.17.20.
    • 63150ef Documentation fixes.
    • 00f0f62 test.js: Remove trailing comma.
    • 846e434 Temporarily use a custom fork of lodash-cli.
    • 5d046f3 Re-enable Travis tests on 4.17 branch.
    • aa816b3 Remove /npm-package.
    • See full diff in compare view
    Maintainer changes

    This version was pushed to npm by bnjmnt4n, a new releaser for lodash since your current version.


    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • Bump handlebars from 4.5.3 to 4.7.7

    Bump handlebars from 4.5.3 to 4.7.7

    Bumps handlebars from 4.5.3 to 4.7.7.

    Changelog

    Sourced from handlebars's changelog.

    v4.7.7 - February 15th, 2021

    • fix weird error in integration tests - eb860c0
    • fix: check prototype property access in strict-mode (#1736) - b6d3de7
    • fix: escape property names in compat mode (#1736) - f058970
    • refactor: In spec tests, use expectTemplate over equals and shouldThrow (#1683) - 77825f8
    • chore: start testing on Node.js 12 and 13 - 3789a30

    (POSSIBLY) BREAKING CHANGES:

    • the changes from version 4.6.0 now also apply in when using the compile-option "strict: true". Access to prototype properties is forbidden completely by default, specific properties or methods can be allowed via runtime-options. See #1633 for details. If you are using Handlebars as documented, you should not be accessing prototype properties from your template anyway, so the changes should not be a problem for you. Only the use of undocumented features can break your build.

    That is why we only bump the patch version despite mentioning breaking changes.

    Commits

    v4.7.6 - April 3rd, 2020

    Chore/Housekeeping:

    Compatibility notes:

    • Restored Node.js compatibility

    Commits

    v4.7.5 - April 2nd, 2020

    Chore/Housekeeping:

    • Node.js version support has been changed to v6+ Reverted in 4.7.6

    Compatibility notes:

    • Node.js < v6 is no longer supported Reverted in 4.7.6

    Commits

    v4.7.4 - April 1st, 2020

    Chore/Housekeeping:

    Compatibility notes:

    ... (truncated)

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
Releases(v2.8)
  • v2.8(Dec 14, 2018)

  • v2.5(Oct 11, 2018)

    It's now possible to create custom relations
    e.g.

    // models/User.js
    this.has('has_posts_written', {
      query: function(store, parentRecords){
        const ids = parentRecords.map(r => r.id)
        const Post = store.Model('Post')
        // query all posts by user_id, group by user_id and count(distinct(id))
        return Post.totalCount().group('user_id').where({user_id: ids})
      },
    
      convert: function(parent, records){
        if(!records) return false
        // records => [{user_id: 1, count: 4}, {user_id: 2, count: 1}]
        // == the result of the above query!
        const result = records.find(r => r.user_id === parent.id)
        if(!result) return false
        return result.count > 0
      }
    })
    

    A custom relation could return anything. In the example above it'll return a boolean value.

    Works with include() like any other relation:
    User.include('has_posts_written')

    Source code(tar.gz)
    Source code(zip)
  • v2.2(Aug 29, 2018)

    The postgres store now supports all geometric data types.

    There are also two new store options externalAttributeName and internalAttributeName for all stores.
    Both options are optional and expect a method in the form of function(fieldName: string): string

    With externalAttributeName you can convert your internal database field names into another format. e.g. from snake_case to camelCase. The conversion is up to you! internalAttributeName should handle the opposite way.

    Source code(tar.gz)
    Source code(zip)
  • v2.0.0(Apr 18, 2018)

    Version 2.0 - whats new?

    Bulk loading

    Relations got rewritten with optional bulk loading:

    const user = await User.limit(3)
    const posts = await Promise.all(users.map(user => user.posts))
    

    will only execute 2 queries! To disable bulk loading see bulkFetch. However, in this case it's better to use const user = await User.include('posts').limit(3)

    Faster preloading

    include was rewritten to load relations in parallel, if possible (SQL only!)

    const users = await User.find(1).include('posts')
    /*
      will execute `SELECT * FROM users WHERE id=1`
      and `SELECT * FROM posts WHERE user_id = 1` in parallel
    */
    

    In V1 the above example would have loaded the data in series.

    Of course this is only possible if the conditions for the first query will contain all information needed to execute the second query!

    Model autoload (SQL only)

    Similar to autoloading model attributes, it's now possible to autoload models.

    const Store = require('openrecord/store/sqlite3')
    
    const store = new Store({
      file: './my-posts-db.sqlite3',
      autoLoad: true // enable autoload
    })
    
    store.ready(async () => {
      const post = await store.Model('Post').find(1) // Post model is automatically available, if a table `posts` is defined in the sqlite3 database before.
      console.log(post)
    })
    

    Classes

    Defining a model via ES6 classes is now possible

    class User extends Store.BaseModel{
      fullName(){
        return `${this.first_name} ${this.last_name}`
      }
    }
    

    GraphQL

    Support for GraphQL with automatic relation loading and more.

    Webpack

    It's now possible to bundle your store via webpack (Version 3 and 4) There is also a Webpack Plugin to cache your data structure inside your bundle. (Faster startup for serverless apps)

    Custom operators

    It's now possible to define custom operators and use the whole power of knex

    // the new operator is called `regexp`
    store.addOperator('regexp', function(field, value, query, condition){
      query.where(field, '~', value.toString().replace(/(^\/|\/$)/g, '')) // naiv conversion of js regexp to postgres regexp!
    })
    // and it will be appended to the `string` type
    store.appendOperator('string', 'regexp')
    

    Query via:

    const user = await User.where({login_regexp: /open.*/})
    

    Everything Promise!

    The whole core was rewritten to use Promises instead of async.

    Docs

    Docs are now available via https://openrecord.js.org

    Breaking Changes to V1

    • plugins and models store config does not take paths anymore. To get the old behavior back, use the automatic model loading plugin
    • paranoid plugin scope to get all records was renamed to withDeleted instead of with_deleted
    • join() does an inner join by default (instead of a left join)
    • Failed validations will now throw an error! Thereforesave, delete, create,... won't return success anymore. Instead it will return the record on success
    • Hooks must return a promise or undefined. The done callback was removed.
    • create, save, destroy, ... won't take callbacks any more. use e.g. record.save().then(callback)
    • Relation records wont be saved anymore. except you set autoSave to true (store or per relation)
    • Accessing a relation via e.g. user.posts will return a then-able object. To access loaded data directly use user._posts (Will return null if not loaded)
    • limit(1) does not return a single record anymore. Use first() or singleRecord() instead
    • logger option on store is no longer available. openrecord now uses the debug module
    • Drop support for NodeJS lower version 4
    Source code(tar.gz)
    Source code(zip)
  • v1.12(Jul 17, 2017)

  • v1.11.0(Jun 3, 2017)

  • v1.10.16(Mar 10, 2017)

  • v1.10.10(Sep 11, 2015)

  • v1.10.2(Aug 21, 2015)

  • v1.10.1(Aug 20, 2015)

  • v1.10.0(Jul 17, 2015)

  • v1.9.0(May 4, 2015)

    You could optionally install node fibers and use the sync() function to do everything synchronous (no callbacks!).

    store.sync(function(){
      var user = User.find(1).exec();
      user.active = false;
      user.save();
    })
    
    Source code(tar.gz)
    Source code(zip)
  • v1.7.0(Jan 19, 2015)

    With version 1.7 OpenRecord adds support for Microsoft`s ActiveDirectory.

    receiving a user with all it's groups is easy:

    var OpenRecord = require('openrecord');
    
    var store = new OpenRecord({
      type: 'activedirectory',
      url: 'ldaps://domain.lan',
      user: 'Domain\\Administrator',
      password: 'password',
      base: 'dc=domain,dc=lan'
    });
    
    
    store.ready(function(){
      var User = store.Model('User');
    
      User.find('cn=Administrator,cn=Users,dc=domain,dc=lan').include('groups').exec(function(admin){
        console.log(admin);
        process.exit(0);
      });
    
    });
    
    Source code(tar.gz)
    Source code(zip)
  • v1.6.3(Nov 13, 2014)

Owner
Philipp Waldmann
Software developer (nodejs, elixir, vuejs, graphql, serverless, postgres) and co-owner of digitalbits.at
Philipp Waldmann
It is a Discord bot whose goal is to make it easier for server owners to create a so-called Staff/Mode Application

Application Bot MeCodes Application Bot It is a Discord bot whose goal is to make it easier for server owners to create a so-called administration sub

null 26 Dec 12, 2022
Plant trees to harvest apples. Sell apples to buy upgrades. Sell apples and wares to make the most money and top the leaderboard!

Happy Harvesters Apple Orchard Game A browser based game that is also mobile friendly so you can finally say "How about THEM apples". Table of Content

Scott Rohrig 7 May 21, 2022
This is a boilerplate for Nodejs (Nestjs/typescript) that can be used to make http server application.

Hexagonal architecture Table of Contents Overview Code architecture source code Service build information Regular user Advanced user Deployment Helm K

Moeid Heidari 20 Sep 13, 2022
Timers for Lost Ark bosses, islands, events, wandering merchants and more! Never miss an event again.

Timers for Lost Ark bosses, islands, events, wandering merchants and more! Never miss an event again. LostArkTimer.app Website Website Features Event

Joshua Kuan 28 Oct 17, 2022
A remote nodejs Cache Server, for you to have your perfect MAP Cache Saved and useable remotely. Easy Server and Client Creations, fast, stores the Cache before stopping and restores it again!

remote-map-cache A remote nodejs Cache Server, for you to have your perfect MAP Cache Saved and useable remotely. Easy Server and Client Creations, fa

Tomato6966 8 Oct 31, 2022
Run a command, watch the filesystem, stop the process on file change and then run the command again...

hubmon Run a command, watch the filesystem, stop the process on file change and then run the command again... Install You can install this command lin

Hubert SABLONNIÈRE 7 Jul 30, 2022
A JavaScript library stores the form-data to the localstorage so you don't have to fill the form again.

form-storage A JavaScript library stores the form-data to the localstorage so you don't have to fill the form again. Installation via npm npm install

appleple 159 Dec 10, 2022
Simple utils to pack arrays, objects and strings to a flat object (and back again).

packrup Simple utils to pack (and unpack) arrays and strings to a flat object. Status: In Development Please report any issues ?? Made possible by my

Harlan Wilton 15 Dec 23, 2022
Make friends through music. Discover great sound tracks on Solana and play them with your buddies :dancer:.

Acoustic Licious COVID-19 has significantly impacted the mental health of children and adults alike. Globally, the population suffering from lonelines

Devyansh Chawla 4 Oct 28, 2022
Great web App to make a list of awesome books to read. Made with ❤️, JavaScript ES6 Modules.

Awesome Books A basic app project built with HTML, CSS and JS to keep track of awesome books. Built With HTML/CSS & JS best practices: Correct use of

Raul Ospina 10 Sep 20, 2022
Reddit Page CLONE using Angular! A repository to contribute at hacktoberfest 2022. Make sure to share love by giving it a star.🌟 Have a great day!

Reddit_tool Reddit Site CLONE using Angular, Springboot and Swagger OpenAI ! Introduction This project was developed with the following technologies:

Momo-Solaris8 4 Oct 20, 2022
Front-end framework with a built-in dark mode and full customizability using CSS variables; great for building dashboards and tools.

This is the main branch of the repo, which contains the latest stable release. For the ongoing development, see the develop branch. Halfmoon Front-end

Tahmid (Halfmoon UI) 2.8k Dec 26, 2022
🍞🎨 Full-featured photo image editor using canvas. It is really easy, and it comes with great filters.

Full featured image editor using HTML5 Canvas. It's easy to use and provides powerful filters. Packages toast-ui.image-editor - Plain JavaScript compo

NHN 5.7k Jan 6, 2023
A lightweight carousel library with fluid motion and great swipe precision

Embla Carousel Embla Carousel is a bare bones carousel library with great fluid motion and awesome swipe precision. It's library agnostic, dependency

David 2.8k Jan 4, 2023
great circle routes in javascript

arc.js Calculate great circles routes as lines in GeoJSON or WKT format. Algorithms from https://edwilliams.org/avform.htm#Intermediate Includes basic

Dane Springmeyer 341 Dec 26, 2022
❤️ JavaScript/TypeScript linter (ESLint wrapper) with great defaults

JavaScript/TypeScript linter (ESLint wrapper) with great defaults Opinionated but configurable ESLint wrapper with lots of goodies included. Enforces

XO 7k Jan 9, 2023
A great application command handler bot for Discord servers!

discord-app-commands-v13 A great multiple application command handler bot for Discord servers! Features Multiple application command handling. Slash c

null 17 Nov 1, 2022
🍞🎨 Full-featured photo image editor using canvas. It is really easy, and it comes with great filters.

Full featured image editor using HTML5 Canvas. It's easy to use and provides powerful filters. ?? Packages toast-ui.image-editor - Plain JavaScript co

NHN 5.7k Dec 28, 2022
A concise collection of classes for PHP, Python, JavaScript and Ruby to calculate great circle distance, bearing, and destination from geographic coordinates

GreatCircle A set of three functions, useful in geographical calculations of different sorts. Available for PHP, Python, Javascript and Ruby. Live dem

null 72 Sep 30, 2022