Giter Club home page Giter Club logo

sequel_uuid_prefix's Introduction

UUID Prefix

This is a Sequel Model plugin that adds [0-9a-z] unique ID prefixed by a custom string.

The prefix isn't stored in the database. Only the Unique ID itself is.

Usage:

class Account < Sequel::Model
  plugin Sequel::Plugins::UUIDPrefix

  uuid_prefix 'a'
end

class User < Sequel::Model
  plugin Sequel::Plugins::UUIDPrefix

  uuid_prefix 'u'
end

# Find an account.
UUIDPrefix.find('a-xxxxxxxx')

# Find a user.
UUIDPrefix.find('u-xxxxxxxx')

user1.uuid_prefix # == 'u'
user1.canonical_uuid # == 'u-abcd1234'

Account['a-xxxxyyyy'] # Returns the account with UUID a-xxxxyyyy

Account.trim_uuid('a-abcd1234') # == 'abcd1234'

sequel_uuid_prefix's People

Watchers

Yamazaki Yasuhiro avatar Masahito Yoshida avatar Axsh-ogawa avatar Zack Adams avatar Kiwamu Okabe avatar Tsunehisa Iwano avatar tkashiwagi avatar Jari Sundell avatar James Cloos avatar Akira Yokokawa avatar 佐々木 厚吉 avatar Richard Potter avatar  avatar Akiyama.k avatar Gyute avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.