Skip to content

Latest commit

 

History

22 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ObjectID

Library to generate MongoDB objectID's

Go Report Card PkgGoDev

Command usage

$ objectid -h
Usage of objectid:
  -format string
        format of objectid: hex, base64 (default "hex")
  -from-time string
        create a new objectid from a date time (RFC3339, $(date -I), $(date -Ihours), $(date -d -Iminutes), $(date -Iseconds)
  -n int
        number of objectid to generate (default 1)
  -separator string
        separator between objectids (default "\n")
  -to-time string
        convert objectid to time

Generate object id

$ objectid
6435f4800000000000000000

Generate object id in base64

$ objectid -format base64
ZiesvNpsbBz8QUGk

Generate multiple object id

$ objectid -n 3
6435f4800000000000000000
6435f4800000000000000001
6435f4800000000000000002

Object id from time

$ objectid -from-time 2023-04-12
6435f4800000000000000000%

Object id to time

$ objectid -to-time 6435f4800000000000000000
2023-04-12 00:00:00 +0000 UTC

Library Usage

go get -u github.com/Ajnasz/objectid
import "github.com/Ajnasz/objectid"


func main() {
    oid := objectid.New()
    fmt.Printf("%s", oid)
}

CLI

Install the cli tool

go install github.com/Ajnasz/objectid/cmd/objectid

or

make build
bin/objectid

About

Go library to generate MongoDB objectid

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages