avram_scoped_id
Version, currently 0.1.02 versions
- 0.2.0latestMay 11, 2020
- 0.1.0not indexedMay 11, 2020
github.com/microgit-com/avram_scoped_id
scoped_id based on query in Avram
Nothing has been indexed for 0.1.0 yet. The tag is recorded, its shard.yml has not been read, so the manifest and dependency list below are empty because they are unknown rather than because they are absent.
Installation
# Add this to your shard.yml
dependencies:
avram_scoped_id:
github: microgit-com/avram_scoped_id
version: ~> 0.1.0Then run:
shards installshard.yml
No shard.yml has been indexed for 0.1.0. You can read it on the repository.
Dependencies
Unknown: the shard.yml for this version has not been read yet.
README
This README is the one indexed from the repository at its latest ref, not from the tag for this version.
avram_scoped_id
An small helper to set an scoped id for the model, based on the query you set as well.
Installation
-
Add the dependency to your
shard.yml:dependencies: avram_scoped_id: github: microgit-com/avram_scoped_id -
Run
shards install -
Require the shard after requiring Avram
If using Lucky, require the shard in your src/shards.cr file after requiring Avram:
# In src/shards.cr
# Put this after `require "avram"`
require "avram_scoped_id"
If not using Lucky, require the shard after Avram:
# In whichever file you require your shards
# Put this after `require "avram"`
require "avram_scoped_id"
Usage
Create column scoped_id in your model, as Int64
You can call it differently if you want, just change to your column in the set method inside the before_save below
class AddScopeIdToArticle::V20200510065019 < Avram::Migrator::Migration::V1
def migrate
alter table_for(Article) do
add scoped_id : Int64, default: 0
end
end
def rollback
# drop table_for(Thing)
end
end
Feel free to add index on the scoped_id for faster queries later on.
Then You add it to the operation where you want to save the new scoped id. Like SaveArticle.
class SaveArticle < Article::SaveOperation
before_save do
AvramScopedId.set column: scoped_id,
query: ArticleQuery.new.team_id(team_id)
end
end
Good thing to know is that variables in the query might fail due to they can be
Nil- So useneedsand set that in the query and if necessary with.not_nil!
Development
TODO: Write development instructions here
Contributing
- Fork it (https://github.com/microgit-com/avram_scoped_id/fork)
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
Contributors
- Håkan Nylén - creator and maintainer
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
0.1.0- Tagged
- May 11, 2020
- Commit
d5853177e55f- Indexed
- not yet
Dependents
No indexed shard depends on this one yet.
Repository
github.com/microgit-com/avram_scoped_id
Metadata
- Created
- Aug 16, 2026
- Updated
- Aug 16, 2026
- Synced
- Aug 16, 2026
- Versions
- 2