-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(binary uuids): implement binary(16) uuids
This commit implements a proof-of-concept binary UUID storage scheme for the cash module. The integration tests have been updated accordingly. **Overview** The introduction of binary uuids means that a little more work must be done in the controllers and sql to insert/retrieve data. Some commands in Node and SQL have been added to ease this process. I'll document these differences as `before` and `after` scenarios. READ Before: ```sql SELECT uuid FROM table; ``` After: ```sql SELECT BUID(uuid) AS uuid FROM table; ``` **Note**: it is important to alias the column with `AS` in order to preserve the property name `uuid`. The command `BUID()` has been added to our MySQL database instance to convert binary uuids into hexadecimal uuids. WRITE Before: ```js var insertSql = 'INSERT INTO table SET ?;'; var updateSql = 'UPDATE table SET ? WHERE uuid = ?;'; var data = { uuid : /** some uuid */, /* other properties ... */ }; db.exec(insertSql, [ data ]).then(/* ... */).catch(/* .. */); db.exec(updateSql, [ data, req.params.uuid ]).then(/* ... */).catch(/* .. */); ``` After: ```js var insertSql = 'INSERT INTO table SET ?;'; var updateSql = 'UPDATE table SET ? WHERE uuid = ?;'; var data = { uuid : /** some uuid */, /* other properties ... */ }; // convert the hex uuid into a binary uuid data.uuid = db.bid(data.uuid); // insert with the new data db.exec(insertSql, [ data ]).then(/* ... */).catch(/* .. */); db.exec(updateSql, [ data, db.bid(req.params.uuid) ]).then(/* ... */).catch(/* .. */); ``` I'd be curious if we can come up with a better API for binary conversions. The currenct method is pragmatic, but possibly unclear.
- Loading branch information
Showing
6 changed files
with
101 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters