@hipsjs/adonis-lucid-uuid
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

Adonis Lucid UUID

Works with @adonisjs/lucid@alpha (^8..) (adonis preview v5)

Adds a decorator to Lucid models for a uuid. Uses the uuid package

📄 Installation

Make sure to install it using npm or yarn.

# npm
npm i --save @hipsjs/adonis-lucid-uuid

# yarn
yarn add @hipsjs/adonis-lucid-uuid

Make sure to register the provider inside .adonisrc.json file.

"providers": [
  "@hipsjs/adonis-lucid-uuid"
]

For TypeScript projects add to tsconfig.json file:

"compilerOptions": {
  "types": [
    "@hipsjs/adonis-lucid-uuid"
  ]
}

🔧 Usage

import { BaseModel } from '@ioc:Adonis/Lucid/Orm'
import { withUuid } from '@ioc:Hipsjs/Lucid/Uuid'

@withUuid({ column: 'uid', version: 'v4' })
export default class User extends BaseModel {
  public uid: string
}

the @withUuid decorator supports the following options:

{
    column?: string
    version?: string
    name?: string
    namespace?: string
    isPrimary?: boolean
}

all options are optional and default to:

{
  column: 'uid',                                      
  version: 'v4', 									
  name: 'yourdomain.com',							
  namespace: '6ba7b810-9dad-11d1-80b4-00c04fd430c8',
  isPrimary: false,
}

Name and namespace option are passed for v3 and v5 of uuid

⚙️ Development

See package.json scripts

Show Your Support

Please give a if this project helped you!

💕 Contributing

If you have any questions or requests or want to contribute to @hipsjs/adonis-lucid-uuid or other packages, please write the issue or send in a Pull Request freely.

Package Sidebar

Install

npm i @hipsjs/adonis-lucid-uuid

Weekly Downloads

4

Version

1.0.1

License

MIT

Unpacked Size

8.26 kB

Total Files

12

Last publish

Collaborators

  • hips1