Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(db): implement db.convert() #368

Merged
merged 1 commit into from
May 3, 2016

Conversation

jniles
Copy link
Collaborator

@jniles jniles commented Apr 29, 2016

This commit implements db.convert() to convert hexadecimal strings on objects into binary representation for insertion into the database. It is demonstrated on both the patient groups controller and enterprises controller.

It is used as described here: #321 (comment)

let data = req.body;

// do some logic

// convert the 'uuid' and 'debtor_uuid' properties to binary using
// db.bid()
data = db.convert(data, ['uuid', 'debtor_uuid']);

// now I can db.exec('INSERT...') or db.exec('UPDATE ...') easily.

It also contains a tiny bug fix by making sure location_id is wrapped in a call to BUID(). I don't think anyone was using this API yet, but it would result in binary data being leaked to the client.


Thank you for contributing!

Before submitting this pull request, please verify that you have:

  • Run your code through JSHint. Check out our styleguide.
  • Run integration tests.
  • Run end-to-end tests.
  • Accurately described the changes your are making in this pull request.

For a more detailed checklist, see the official review checklist that this PR will be evaluated against.

Ensuring that the above checkboxes are completed will help speed the review process
and help build a stronger application. Thanks!

@jniles jniles force-pushed the feature-db-convert branch 3 times, most recently from 6fd544c to 3ea2eb5 Compare May 2, 2016 09:05
This commit implements `db.convert()` to convert hexadecimal strings on
objects into binary representation for insertion into the database.  It
is demonstrated on both the patient groups controller and enterprises
controller.

It is used as described here: IMA-WorldHealth#321 (comment)
```js
let data = req.body;

// do some logic

// convert the 'uuid' and 'debtor_uuid' properties to binary using
// db.bid()
data = db.convert(data, ['uuid', 'debtor_uuid']);

// now I can db.exec('INSERT...') or db.exec('UPDATE ...') easily.
It might help clean up the code a bit.
```
@jniles
Copy link
Collaborator Author

jniles commented May 3, 2016

@sfount, could I get a review?

@sfount
Copy link
Contributor

sfount commented May 3, 2016

Code LGTM.

@sfount sfount merged commit 8bccce7 into IMA-WorldHealth:master May 3, 2016
@jniles jniles deleted the feature-db-convert branch May 3, 2016 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants