All Projects → seegno → bookshelf-json-columns

seegno / bookshelf-json-columns

Licence: other
Parse JSON columns with Bookshelf.js

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to bookshelf-json-columns

Bookshelf
A simple Node.js ORM for PostgreSQL, MySQL and SQLite3 built on top of Knex.js
Stars: ✭ 6,252 (+9668.75%)
Mutual labels:  sqlite, bookshelf
BookReader
📕 "任阅" 网络小说阅读器,3D翻页效果、txt/pdf/epub书籍阅读、Wifi传书~
Stars: ✭ 6,113 (+9451.56%)
Mutual labels:  bookshelf
bookshelf-advanced-serialization
Plugin for Bookshelf.js supporting advanced serialization behavior
Stars: ✭ 17 (-73.44%)
Mutual labels:  bookshelf
jsonapi-mapper
JSON API-Compliant Serialization for your Node ORM
Stars: ✭ 41 (-35.94%)
Mutual labels:  bookshelf
GitHubKotlinMPPSample
No description or website provided.
Stars: ✭ 15 (-76.56%)
Mutual labels:  sqlite
sync-client
SyncProxy javascript client with support for all major embedded databases (IndexedDB, SQLite, WebSQL, LokiJS...)
Stars: ✭ 30 (-53.12%)
Mutual labels:  sqlite
qtorm
Object-Relational Mapping Module for Qt
Stars: ✭ 16 (-75%)
Mutual labels:  sqlite
thinkorm
A flexible, lightweight and powerful Object-Relational Mapper for Node.js. Support TypeScript!!
Stars: ✭ 33 (-48.44%)
Mutual labels:  knex
ccxx
This is a cross-platform library software library about c, c ++, unix4, posix. Include gtest, benchmark, cmake, process lock, daemon, libuv, lua, cpython, re2, json, yaml, mysql, redis, opencv, qt, lz4, oci ... https://hub.docker.com/u/oudream
Stars: ✭ 31 (-51.56%)
Mutual labels:  sqlite
microlight
A fully IndieWeb-compatible PHP blogging engine
Stars: ✭ 35 (-45.31%)
Mutual labels:  sqlite
Ionic-2-sqlite-demo
Simple demo to show how to work with Sqlite Storage in Ionic 2
Stars: ✭ 20 (-68.75%)
Mutual labels:  sqlite
SQLitePractice
数据库案例:1.使用时间和日期函数,增,查时间字段。2.利用ContentProvider,CursorLoader,SQLite实现数据库的观察者模式。3.RxJava,SQLBrite实现数据库的观察者模式。4.拷贝外部db文件到数据库中
Stars: ✭ 21 (-67.19%)
Mutual labels:  sqlite
vsql
A sql query builder for V
Stars: ✭ 35 (-45.31%)
Mutual labels:  knex
InvestmentDataSampleApp
This app utilizes a SQLite databse, MVVM, along with these Xamarin.Forms controls: Search Bar, Picker, Grid, StackLayout, Navigation Page, ListView, ViewCell. It also shows how to tweak the UI to best appear on larger tablet screens.
Stars: ✭ 56 (-12.5%)
Mutual labels:  sqlite
closql
Store EIEIO objects using EmacSQL
Stars: ✭ 23 (-64.06%)
Mutual labels:  sqlite
sack.vfs
Node addon which adds a virtual file system interface; websockets; json(6) parsing; sql support(sqlite,odbc); javascript sched_yield; ssl certificate generation; more...
Stars: ✭ 29 (-54.69%)
Mutual labels:  sqlite
recognition-text
A recognition-text application which recognize any text from an image with 98% to 100% accuracy. Gave support for 92 languages and translate your recognized text to 6 supported languages.
Stars: ✭ 22 (-65.62%)
Mutual labels:  sqlite
database
Database Abstraction Layer, Schema Introspection, Schema Generation, Query Builders
Stars: ✭ 25 (-60.94%)
Mutual labels:  sqlite
acid-store
A library for secure, deduplicated, transactional, and verifiable data storage
Stars: ✭ 48 (-25%)
Mutual labels:  sqlite
reactnative-typescript
Playground and evolution of learnings done in react native with typescript
Stars: ✭ 28 (-56.25%)
Mutual labels:  sqlite

bookshelf-json-columns

This Bookshelf.js plugin enables you to define which model columns have JSON format, preventing manual hook definition for each model with JSON columns.

Status

npm version node version build status coverage status

Installation

Install the package via npm:

$ npm install --save bookshelf-json-columns

Usage

Require and register the bookshelf-json-columns plugin:

var bookshelf = require('bookshelf')(knex);
var jsonColumns = require('bookshelf-json-columns');

bookshelf.plugin(jsonColumns);

Define which columns have JSON format with the jsonColumns class property:

bookshelf.Model.extend({
  tableName: 'foo'
}, {
  jsonColumns: ['bar', 'biz']
});

If you're using ES6 class syntax, define jsonColumns as static property:

class Model extends bookshelf.Model {
  get tableName() {
    return 'foo';
  }

  static jsonColumns = ['bar', 'biz'];
}

This plugin extends the initialize and save methods of Bookshelf's Model, so if you are also extending or overriding them on your models make sure to call their prototype after your work is done:

bookshelf.Model.extend({
  initialize: function() {
    // Do some stuff.
    store.addModel(this);

    // Call the `initialize` prototype method.
    bookshelf.Model.prototype.initialize.apply(this, arguments);
  },
  save: function() {
    // Do some stuff.
    store.validateModel(this);

    // Call the `save` prototype method.
    bookshelf.Model.prototype.save.apply(this, arguments);
  },
  tableName: 'foo'
}, {
  jsonColumns: ['bar', 'biz']
});

Contributing

Contributions are welcome and greatly appreciated, so feel free to fork this repository and submit pull requests.

bookshelf-json-columns supports PostgreSQL, SQLite3 and MySQL. You can find test suites for all these database engines in the test folder.

Setting up

  • Fork and clone the bookshelf-json-columns repository.
  • Duplicate all .dist knexfiles and update them to your needs.
  • Make sure all the tests pass:
$ npm test

Linting

bookshelf-json-columns enforces linting using ESLint with the Seegno-flavored ESLint config. We recommend you to install an eslint plugin in your editor of choice, although you can run the linter anytime with:

$ eslint src test

Pull Request

Please follow these advices to simplify the pull request workflow:

  • If you add or enhance functionality, an update of README.md usage section should be part of the PR.
  • If your PR fixes a bug you should include tests that at least fail before your code changes and pass after.
  • Keep your branch rebased and fix all conflicts before submitting.
  • Make sure Travis build status is ok.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].