Giter Club home page Giter Club logo

base_model's People

Contributors

dkhalil avatar meyercm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

base_model's Issues

Compile warning when implement `create_changeset`: got "@impl BaseModel" for function create_changeset/1 but no behaviour was declared

Hi @meyercm, thank you so much for making this lib. It's been a great help for me. There is a tiny issue though, when I define a create_changeset in my schema, there is this compiling error said:
got "@impl BaseModel" for function create_changeset/1 but no behaviour was declared.
The code of the schema looked like this:

defmodule AnnualPlan do
  use Ecto.Schema
  use BaseModel, repo: MyApp.Repo

  import Ecto.Changeset

  @primary_key {:id, :binary_id, autogenerate: true}
  @foreign_key_type :binary_id
  schema "annual_plans" do
    field(:body, :string)
    field(:year, :string)
    belongs_to(:user, MyApp.Accounts.User, type: :integer)

    timestamps()
  end

  @impl BaseModel
  def create_changeset(params) do
    %__MODULE__{}
    |> cast(params, [:year, :body, :user_id])
    |> validate_required([:year, :body, :user_id])
  end
end

Although the create_changeset function still works, it would be great if there is no compile warning. Was I missing something?

Any plans for `Model.last` and Query method?

Hi @meyercm , sorry for coming to complain again. Do you have any plans for generating a last method(order_by: [desc: :inserted_at]) for model, just like ActiveRecord#last. I personally find it very useful.
Another feature I found useful is generating a bunch of methods that returns a Ecto.Query. These methods could be bundled up in a generated Module, like Model.Query.query_method.
For example.
User.Query.where(username: "chris") would return a Query similar to from(User, where: [username: "chris"]). This would simplify lots of boilerplate code when composing query or when using preload.
Sorry for my poor English, I hope I've made myself clear.

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.