Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/bookshelf/case-converter-plugin

Bookshelf plugin for handling the conversion between the database's snake_cased and a model's camelCased properties automatically.
https://github.com/bookshelf/case-converter-plugin

bookshelf bookshelf-plugin bookshelfjs javascript plugin

Last synced: about 1 month ago
JSON representation

Bookshelf plugin for handling the conversion between the database's snake_cased and a model's camelCased properties automatically.

Awesome Lists containing this project

README

        

# Bookshelf Case Converter Plugin

[![Build Status](https://travis-ci.com/bookshelf/case-converter-plugin.svg?branch=master)](https://travis-ci.com/bookshelf/case-converter-plugin) [![Greenkeeper badge](https://badges.greenkeeper.io/bookshelf/case-converter-plugin.svg)](https://greenkeeper.io/)

This is a plugin for the [Bookshelf Node.js ORM](https://bookshelfjs.org/) that handles the conversion between the
database's snake_cased and a model's camelCased properties automatically.

## How to use

First install the package:

npm install bookshelf-case-converter-plugin

Then load the plugin using `bookshelf.plugin('bookshelf-case-converter-plugin')`. No further action is required, since
the plugin will automatically convert model attributes between snake_case and camelCase.

## Limitations

Note that there are some limitations to the way this plugin works. When you access query methods directly, there will be
no conversion, meaning that you have to use the actual database column names in this case. The following methods do no
work with this plugin yet:

- [model.query()](https://bookshelfjs.org/api.html#Model-instance-query)
- [model.where()](https://bookshelfjs.org/api.html#Model-instance-where)
- [collection.query()](https://bookshelfjs.org/api.html#Collection-instance-query)
- [collection.where()](https://bookshelfjs.org/api.html#Collection-instance-where)