therealreal / ecto-ulid Goto Github PK
View Code? Open in Web Editor NEWEcto ULID
License: MIT License
Ecto ULID
License: MIT License
the mix.sx forcce ecto version to 2.x, it's propably compatible with 3.x also ?
Thus it can be used with ecto 3.x as it.
Since the underlying data type in postgres is uuid
DB clients render the ULID as a UUID. I can query using the DB client fine with these IDs, but how do I query for records from within iex
eg. iex(2)> MyApp.Repo.get!(Blog, "<TBD>")
I tried a couple of encoding/decoding ideas, but I'm drawing a blank.
I'm trying to use ULIDs as my primary keys in the DB. But when I try to run my Phoenix app Ecto complains about string format of ULID. It seams it cannot
(Ecto.Query.CastError) lib/app/user.ex:55: value `"01F0PBGGWZFR03KSA7H3GKQE6K"` cannot be dumped to type :binary_id in query:
from p0 in Habiter.User.Profile,
where: p0.user_id == ^"01F0PBGGWZFR03KSA7H3GKQE6K",
select: p0
I'm giving it id I've got from user already in the DB. It should work but it doesn't. There seams to be an easy fix. Problem is then it wouldn't be an ULID format. But as I've seen in https://github.com/erikreedstrom/ulid repo, it is possible to generate UUID format and work with that.
If there's an interest I'm willing to send you a PR with that. Because I don't think it's efficient to use strings as primary keys.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.