@actually_connor/uuid 中文文档教程
@actually_connor/uuid
一个 JavaScript 库,为 uuid 包提供类似“ramsey/uuid”的接口。
@actually_connor/uuid 是一个 JavaScript 库,用于生成和处理普遍唯一的 标识符(UUID)。 它为 uuid 包,
该项目遵守行为准则。 通过参与此项目及其社区,您应该 坚持这个准则。
Quickstart
- Install
npm i --save @actually_connor/uuid
- Generate a UUID (ES6 module syntax)
import { Uuid } from '@actually_connor/uuid';
const uuid = Uuid.uuid4();
...或使用 CommonJS 语法:
const { Uuid } = require('@actually_connor/uuid');
const uuid = Uuid.uuid4();
Documentation
Use in Database - MySQL
在数据库中保存 UUID 值的推荐用途是创建一个BINARY(16)
数据库中的列。 保留 UUID 时,您可以 UNHEX
UUID 的十六进制表示。
TypeORM
await this.model
.createQueryBuilder()
.insert()
.into(Table)
.values({
uuid: () => `UNHEX('${Uuid.uuid4().getHex()}')`,
})
.execute();
MySQL
INSERT INTO `ActivityDefinition` (`uuid`)
VALUES('UNHEX("616343E4FC6746A598DC73C39C873F34")');
Contributing
欢迎投稿! 要做出贡献,请熟悉 CONTRIBUTING.md。
Copyright and License
@actually_connor/uuid 库版权所有 © Connor Smyth 和 根据麻省理工学院许可证 (MIT) 获得许可使用。 请参阅 LICENSE 了解更多 信息。
@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-like interface to the uuid package that
This project adheres to a code of conduct. By participating in this project and its community, you are expected to uphold this code.
Quickstart
- Install
npm i --save @actually_connor/uuid
- Generate a UUID (ES6 module syntax)
import { Uuid } from '@actually_connor/uuid';
const uuid = Uuid.uuid4();
… or using CommonJS syntax:
const { Uuid } = require('@actually_connor/uuid');
const uuid = Uuid.uuid4();
Documentation
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
await this.model
.createQueryBuilder()
.insert()
.into(Table)
.values({
uuid: () => `UNHEX('${Uuid.uuid4().getHex()}')`,
})
.execute();
MySQL
INSERT INTO `ActivityDefinition` (`uuid`)
VALUES('UNHEX("616343E4FC6746A598DC73C39C873F34")');
Contributing
Contributions are welcome! To contribute, please familiarize yourself with CONTRIBUTING.md.
Copyright and License
The @actually_connor/uuid library is copyright © Connor Smyth and licensed for use under the MIT License (MIT). Please see LICENSE for more information.