Have you ever wondered if you could just write one Ecto query and use it both for an SQL database and Erlang's ETS, DETS or Mnesia?
Whether you are doing early prototyping or looking for an easy way to do pass-through cache, let Ecto do the heavy lifting for you, with one schema and multiple backends!
If available in Hex, the package can be installed
by adding ecto_qlc
to your list of dependencies in mix.exs
:
def deps do
[
{:ecto_qlc, "~> 0.1.0"}
]
end
Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/ecto_qlc.
The following are the current limitations. Most of these can be implemented and others might not even make sense to implement, like placeholders.
- Subqueries are only supported without parent_as since that would require implementation of a query planner.
- Combinations are not supported, but could be supported in a similar way as suqueries.
- Windows are not supported.
- Joins are limited to merge_join or nested_join, the qual: :left, :right, :inner, and etc will not affect the result.
- CTE are not supported.
- Query locks are only supported in the mnesia adapter, and only read, write or sticky_write. global locks are not supported.
- Placeholders are not supported.
- On_conflict is not supported.
- Fragments are not supported in select and has limited support in where clauses where the string can only contain valid Erlang code.
- Queries are not cached
- No automatic clustering
Can be found under the examples directory.
- Building a simple cache with Ecto in 66 lines or
- Building a simple job queue with Ecto in 46 lines or
Most of the inspiration for this adapter comes from Ecto SQL and Etso.
Below is a non-exhaustive list of similar projects:
- https://github.com/elixir-ecto/ecto_sql
- https://github.com/meh/amnesia
- https://github.com/sheharyarn/memento
- https://github.com/Nebo15/ecto_mnesia
- https://github.com/evadne/etso
- https://github.com/wojtekmach/ets_ecto
- https://gitlab.com/patatoid/ecto3_mnesia
- https://github.com/Logflare/ecto3_mnesia
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.