https://github.com/actuallyconnor/uuid
A JavaScript library that provides a 'ramsey/uuid'-like interface for the uuid package
https://github.com/actuallyconnor/uuid
Last synced: 15 days ago
JSON representation
A JavaScript library that provides a 'ramsey/uuid'-like interface for the uuid package
- Host: GitHub
- URL: https://github.com/actuallyconnor/uuid
- Owner: ActuallyConnor
- License: mit
- Created: 2022-02-20T23:51:19.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-11-04T22:08:12.000Z (almost 3 years ago)
- Last Synced: 2025-10-05T09:28:34.809Z (23 days ago)
- Language: TypeScript
- Homepage:
- Size: 1.22 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
@actually_connor/uuid
A JavaScript library that provides a 'ramsey/uuid'-like interface for the uuid package.
@actually_connor/uuid is a JavaScript library for generating and working with universally unique
identifiers (UUIDs). It provides a [ramsey/uuid][ramseyuuid]-like interface to the [uuid][] package that
This project adheres to a [code of conduct](CODE_OF_CONDUCT.md).
By participating in this project and its community, you are expected to
uphold this code.
## Quickstart
1. Install
```bash
npm i --save @actually_connor/uuid
```
2. Generate a UUID (ES6 module syntax)
```javascript
import { Uuid } from '@actually_connor/uuid';
const uuid = Uuid.uuid4();
```
... or using CommonJS syntax:
```javascript
const { Uuid } = require('@actually_connor/uuid');
const uuid = Uuid.uuid4();
```
## Documentation
[@actually_connor/uuid docs](https://uuid.connorsmyth.com/Uuid.html)
## Use in Database - MySQL
The recommended use for saving UUID values in the database would be to create a `BINARY(16)` column in the database.
When persisting the UUIDs you can `UNHEX` the hexadecimal representation of the UUID.
### TypeORM
```javascript
await this.model
.createQueryBuilder()
.insert()
.into(Table)
.values({
uuid: Uuid.uuid4().getBuffer(),
})
.execute();
```
```javascript
await this.model
.createQueryBuilder()
.where('uuid = :uuid', { uuid: uuid.getBuffer() })
.getOne();
```
## Contributing
Contributions are welcome! To contribute, please familiarize yourself with
[CONTRIBUTING.md](CONTRIBUTING.md).
## Copyright and License
The @actually_connor/uuid library is copyright © [Connor Smyth](https://connorsmyth.com) and
licensed for use under the MIT License (MIT). Please see [LICENSE][] for more
information.
[uuid]: https://www.npmjs.com/package/uuid
[rfc4122]: http://tools.ietf.org/html/rfc4122
[conduct]: https://github.com/ActuallyConnor/uuid/blob/main/CODE_OF_CONDUCT.md
[ramseyuuid]: https://github.com/ramsey/uuid
[npm]: https://www.npmjs.com/
[contributing.md]: https://github.com/ActuallyConnor/uuid/blob/main/CONTRIBUTING.md
[license]: https://github.com/ActuallyConnor/uuid/blob/main/LICENSE