All Projects → inaka → Sumo_db

inaka / Sumo_db

Licence: apache-2.0
Erlang Persistency Framework

Programming Languages

erlang
1774 projects

Projects that are alternatives of or similar to Sumo db

Adminer Custom
Customizations for Adminer, the best database management tool written in PHP.
Stars: ✭ 99 (-39.26%)
Mutual labels:  database-management, mysql, mongodb, elasticsearch
Dev Setup
macOS development environment setup: Easy-to-understand instructions with automated setup scripts for developer tools like Vim, Sublime Text, Bash, iTerm, Python data analysis, Spark, Hadoop MapReduce, AWS, Heroku, JavaScript web development, Android development, common data stores, and dev-based OS X defaults.
Stars: ✭ 5,590 (+3329.45%)
Mutual labels:  mysql, mongodb, elasticsearch
Notebook
🍎 笔记本
Stars: ✭ 381 (+133.74%)
Mutual labels:  mysql, mongodb, elasticsearch
Pifpaf
Python fixtures and daemon managing tools for functional testing
Stars: ✭ 161 (-1.23%)
Mutual labels:  mysql, mongodb, elasticsearch
Blog
Everything about database,business.(Most for PostgreSQL).
Stars: ✭ 6,330 (+3783.44%)
Mutual labels:  mysql, mongodb, pgsql
Yiigo
🔥 Go 轻量级开发通用库 🚀🚀🚀
Stars: ✭ 304 (+86.5%)
Mutual labels:  mysql, mongodb, pgsql
Mall Swarm
mall-swarm是一套微服务商城系统,采用了 Spring Cloud Hoxton & Alibaba、Spring Boot 2.3、Oauth2、MyBatis、Docker、Elasticsearch、Kubernetes等核心技术,同时提供了基于Vue的管理后台方便快速搭建系统。mall-swarm在电商业务的基础集成了注册中心、配置中心、监控中心、网关等系统功能。文档齐全,附带全套Spring Cloud教程。
Stars: ✭ 7,874 (+4730.67%)
Mutual labels:  mysql, mongodb, elasticsearch
Spring Boot Enterprise Application Development
Spring Boot Enterprise Application Development.《Spring Boot 企业级应用开发实战》
Stars: ✭ 261 (+60.12%)
Mutual labels:  mysql, mongodb, elasticsearch
Phalcon Vm
Vagrant configuration for PHP7, Phalcon 3.x and Zephir development.
Stars: ✭ 43 (-73.62%)
Mutual labels:  mysql, mongodb, elasticsearch
Mall Learning
mall学习教程,架构、业务、技术要点全方位解析。mall项目(40k+star)是一套电商系统,使用现阶段主流技术实现。涵盖了SpringBoot 2.3.0、MyBatis 3.4.6、Elasticsearch 7.6.2、RabbitMQ 3.7.15、Redis 5.0、MongoDB 4.2.5、Mysql5.7等技术,采用Docker容器化部署。
Stars: ✭ 10,236 (+6179.75%)
Mutual labels:  mysql, mongodb, elasticsearch
Szt Bigdata
深圳地铁大数据客流分析系统🚇🚄🌟
Stars: ✭ 826 (+406.75%)
Mutual labels:  mysql, mongodb, elasticsearch
Mall
mall项目是一套电商系统,包括前台商城系统及后台管理系统,基于SpringBoot+MyBatis实现,采用Docker容器化部署。 前台商城系统包含首页门户、商品推荐、商品搜索、商品展示、购物车、订单流程、会员中心、客户服务、帮助中心等模块。 后台管理系统包含商品管理、订单管理、会员管理、促销管理、运营管理、内容管理、统计报表、财务管理、权限管理、设置等模块。
Stars: ✭ 54,797 (+33517.79%)
Mutual labels:  mysql, mongodb, elasticsearch
Spring Boot 2.x Examples
Spring Boot 2.x code examples
Stars: ✭ 104 (-36.2%)
Mutual labels:  mysql, mongodb, elasticsearch
Blog
我的日记
Stars: ✭ 110 (-32.52%)
Mutual labels:  mysql, mongodb, elasticsearch
Transformalize
Configurable Extract, Transform, and Load
Stars: ✭ 125 (-23.31%)
Mutual labels:  mysql, elasticsearch
Mdserver Mac
mdserver (mac version, secondary development)
Stars: ✭ 121 (-25.77%)
Mutual labels:  mysql, mongodb
Notes
👋 如果有一天我失忆了,忘记了所有的前端知识,我希望这个项目能让我很快掌握
Stars: ✭ 126 (-22.7%)
Mutual labels:  mysql, mongodb
Zhttp
基于swoole的异步轻量级web框架,内部封装协程异步非阻塞全套mysql、redis、mongo、memcached连接池,可以轻松start、reload、stop,加入数据库的查询模块,框架已经封装好近乎同步写法,底层异步调用
Stars: ✭ 131 (-19.63%)
Mutual labels:  mysql, mongodb
Docs
《数据采集从入门到放弃》源码。内容简介:爬虫介绍、就业情况、爬虫工程师面试题 ;HTTP协议介绍; Requests使用 ;解析器Xpath介绍; MongoDB与MySQL; 多线程爬虫; Scrapy介绍 ;Scrapy-redis介绍; 使用docker部署; 使用nomad管理docker集群; 使用EFK查询docker日志
Stars: ✭ 118 (-27.61%)
Mutual labels:  mysql, mongodb
Griffon Vm
Griffon Data Science Virtual Machine
Stars: ✭ 128 (-21.47%)
Mutual labels:  mysql, elasticsearch

Stories in Ready

sumo_db

Build Status

About

This is a work in progress. There's also an article about sumo_db. This articles might be a little outdated by now, but can still provide some basic information on how to get started.

sumo_db aims to ease db access for erlang applications. It offers a very simple persistance layer capable of interacting with different db's, while offering a consistent api to your code.

Contact Us

If you find any bugs or have a problem while using this library, please open an issue in this repo (or a pull request :)).

Overview

  • sumo_db gives you a standard way to define your db schema, regardless of the db implementation (mongo, mysql, redis, elasticsearch, etc.).

  • Your entities encapsulate behavior in code (i.e. functions in a module) and state in a sumo:doc() implementation.

  • sumo is the main module. It translates to and from sumo internal records into your own state.

  • Each store is managed by a worker pool of processes, each one using a module that implements sumo_store and calls the actual db driver (e.g: sumo_store_mnesia).

  • Some native domain events are supported, that are dispatched through a gen_event:notify/2 automatically when an entity is created, updated, deleted. Also when a schema is created and when all entities of a given type are deleted. Events are described in this article.

  • Full conditional logic support when using find_by/2 and delete_by/2 function. You can find more information about the syntax of this conditional logic operators here.

  • Support for sorting (asc or desc) based on multiple fields unsing find_by/5 and find_all/4 functions. For example this [{age, desc}, {name, asc}]] will sort descendently by age and ascendently by name.

  • Support for docs/models validations through sumo_changeset (check out the Changeset section).

Backends, Stores and Repositories modules

These three concepts have a specific meaning in the context of sumo_db.

  • Backend: establishes and holds a single Database instance connection.

  • Store: implements the specific operations that modify the contents of the backend and retrieves the information it holds.

  • Repository: the application that uses sumo_db should implement one repository for each entity that's defined in it. The repository is the module that bridges the model and the store.

Supported Backends/Adapters

Implementing an Adapter

To implement an adapter, you must implement two specific behaviours:

You can check the implemented adapters mentioned above in order to have a better idea about how to build a custom adapter from scratch.

Events

Sumo dispatches events when things happen. An Event has this structure:

{EventId, Model, Event, Args}
  • EventId is a reference() which identifies the event
  • Model is the model where the event happend, for example, if we are creating a new entitiy in the model people the value of Model would be people.
  • Event is the type of the event.
  • Args extra data sent.

Supported types of events:

  • pre_persisted just before persisting some entity. This event has the entity we want to persist as Args. It is dispatched on this function:
    • sumo:persist/2
  • persisted just after persisting some entity. This event has the persisted entity as Args. This Event has the same EventId as its pre_persisted event. It is dispatched on this function:
    • sumo:persist/2
  • pre_delete_all just before deleting all entities for a model. This event has no Args. It is dispatched on this function:
    • sumo:delete_all/1
  • deleted_all just after deleting all entities for a model. This event has no Args. This Event has the same EventId as its pre_delete_all event. It is dispatched on this function:
    • sumo:delete_all/1
  • pre_deleted just before deleting an entity. This event has the entity id as Args. It is dispatched on this function:
    • sumo:delete/2
  • deleted just after deleting an entity. This event has the entity id as Args. This Event has the same EventId as its pre_deleted event. It is dispatched on this function:
    • sumo:delete/2
  • pre_deleted_total just before deleting by some delete conditions. This event has the sumo conditions as Args. It is dispatched on this function:
    • sumo:delete_by/2
  • deleted_total just after deleting by some delete conditions. This event has a list with the number of entities deleted and the delete conditions as Args. This Event has the same EventId as its pre_deleted_total event. It is dispatched on this function:
    • sumo:delete_by/2
  • pre_schema_created just before creating a sumo schema. This event has no Args. It is dispatched on this function:
    • sumo:create_schema/2
  • schema_created just after creating a sumo schema. This event has no Args. This Event has the same EventId as its pre_schema_created event. It is dispatched on this function:
    • sumo:create_schema/2

Sumo requires users to add their own gen_event's in order to handle those events. In order to add them Users have to configure sumo properly. In the config file we can add them like this under sumo_db configuration:

{events, [
   {'_', sumo_test_people_events_manager},
   {people, sumo_test_people_events_manager}
 ]}

Sumo allows us to add a gen_event to one type of model (i.e. people) or for all ('_').

Changeset

This feature is inspired by Elixir Ecto.Changeset, and the module that implements this feature is sumo_changeset.

Changeset Usage Example

NOTE: This example uses FancyFlow in order to pipe changeset functions in a nicer way.

%% suppose you have a model/doc `person`, and that module provides a function
%% to encapsulate model/doc creation
Person = person:new(<<"John">>, <<"Doe">>),

%% create the set of params/changes
Params = #{age => 33, id => 1, <<"last_name">> => <<"other">>},

%% run the changeset
Changeset = [pipe](people,
  sumo_changeset:cast(_, Person, Params, [id, first_name, last_name, age, status]),
  sumo_changeset:validate_required(_, [id, last_name, status]),
  sumo_changeset:validate_inclusion(_, status, [<<"active">>, <<"blocked">>]),
  sumo_changeset:validate_number(_, age, [{less_than_or_equal_to, 18}]),
  sumo_changeset:validate_length(_, last_name, [{min, 3}]),
  sumo_changeset:validate_format(_, last_name, <<"^[a-zA-Z]">>)),

Examples

See: examples/blog for a full example. To run it, while being in the top level directory:

make all blog

See: examples/custom_store for creating your own Store. To run it, follow the instructions in this README

Running Dialyzer

$ rebar3 dialyzer

Running Tests

$ rebar3 ct

Change Log

All notable changes to this project will be documented in the CHANGELOG.md.

Contributors

We want to thank all of our contributors for their hard work 💪.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].