- ๐ Ruby
- ๐ JavaScript (React.js and Vue.js)
- ๐ PHP
- ๐ณ Docker
- ๐ฆ Rust
- ๐น Go
Easy Record (easy_record) is a lightweight gem based on ActiveRecord, you can relate models only so far.
Home Page: https://ricvillagrana.github.io/easy-record/
License: MIT License
Right now we have this way to associate two records:
Assuming that
list
is aList
instance.
Item.new(name: 'Item name', list_id: list.id)
But this way is cleaner and better (UPDATE TO THIS):
Item.new(name: 'Item name', list: list)
Also, would be nice to have this kind of assignments:
list.tasks.append(task)
task.list = list
class Person < EasyRecord
field :name, String
end
person = Person.new(name: 'John')
# If we want to "clear" the name assigning `nil`, we will ge this error:
# RuntimeError: name cannot receive type `NilClass` because it is defined as `String`
person.name = nil
person.name
should be able to get a nil
assignment.
Validations are always needed. Currently, datatype is validated but I think it's also great having custom validations.
Example:
class Person < EasyRecord
field name, String
# The lambda funciton should return a boolean.
validate :name, -> (name) { name.size < 50 }
end
Current:
class List < EasyRecord
field :name, String
belongs_to :user, { class_name: 'User' }, 'user_id'
has_many :tasks, class_name: 'Task'
end
New behaviour:
class List < EasyRecord
field :name, String
belongs_to :user # it will take class_name `User` and the key `user_id`
has_many :tasks # it will pluralize and take the `Task` class_name.
end
We need to save our records in json structures.
The files should be places on storage/json/{model_name}.json
ids
method to get an array of ids.pluck
which take an attribute from the model lists and return an array of the attribute values.ids
method.pluck
method.Person.ids # => ['8652b710-cb9f-0137-1165-2cbc32ad1b49', '8652b710-cb9f-0137-1165-2cbc32ad1b50']
Person.pluck :name # => ['John', 'Mike', 'Robin', 'Hannah']
Update readme and add examples directory.
Is needed to have test for this library.
Please use Minitest.
Drop CSV save feature. to only have save
method
Fix the code to follow rubocop guides.
Currently I have a method called has_many_simple
, but I think that has_many_directly
is a better name.
The method is in the associations.rb file.
Feel free to suggest another name if you think is better.
Currently, is needed to have the list_id
in the attr_accessor
, but would be nice if we can avoid this and only passing the name in the belongs_to
.
class List < EasyRecord
attr_accessor :name
has_many :tasks, class_name: 'Task'
end
class Task < EasyRecord
attr_accessor :name, :done, :list_id
belongs_to :list, { class_name: 'List' }, :list_id
end
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.