All Projects → kwrooijen → Gungnir

kwrooijen / Gungnir

Licence: mit
A fully featured, data-driven database library for Clojure.

Programming Languages

clojure
4091 projects

Projects that are alternatives of or similar to Gungnir

Graph
Graph is a semantic database that is used to create data-driven applications.
Stars: ✭ 855 (+677.27%)
Mutual labels:  data-driven, database
Nova
NOVA is a tool for annotating and analyzing behaviours in social interactions. It supports Annotators using Machine Learning already during the coding process. Further it features both, discrete labels and continuous scores and a visuzalization of streams recorded with the SSI Framework.
Stars: ✭ 110 (+0%)
Mutual labels:  database
Vue Table Dynamic
🎉 A dynamic table with sorting, filtering, editing, pagination, multiple select, etc.
Stars: ✭ 106 (-3.64%)
Mutual labels:  data-driven
Tableqa
AI Tool for querying natural language on tabular data.
Stars: ✭ 109 (-0.91%)
Mutual labels:  database
Laravel Settings
Store key value pair in database as settings
Stars: ✭ 107 (-2.73%)
Mutual labels:  database
Covoiturage Libre
UNMAINTAINED
Stars: ✭ 109 (-0.91%)
Mutual labels:  database
Lyrics
📄 Open Lyrics Database
Stars: ✭ 106 (-3.64%)
Mutual labels:  database
Spring Data Mock
Mock facility for Spring Data repositories
Stars: ✭ 110 (+0%)
Mutual labels:  database
Libpq.jl
A Julia wrapper for libpq
Stars: ✭ 109 (-0.91%)
Mutual labels:  database
Etcd
Distributed reliable key-value store for the most critical data of a distributed system
Stars: ✭ 38,238 (+34661.82%)
Mutual labels:  database
Awesome Bigdata
A curated list of awesome big data frameworks, ressources and other awesomeness.
Stars: ✭ 10,478 (+9425.45%)
Mutual labels:  database
Monetdblite
MonetDB reconfigured as a library
Stars: ✭ 107 (-2.73%)
Mutual labels:  database
Online Shopping System
demo
Stars: ✭ 110 (+0%)
Mutual labels:  database
Unqlite
An Embedded NoSQL, Transactional Database Engine
Stars: ✭ 1,583 (+1339.09%)
Mutual labels:  database
Ship Hold
data access framework for Postgresql on nodejs
Stars: ✭ 110 (+0%)
Mutual labels:  database
Pg stat kcache
Gather statistics about physical disk access and CPU consumption done by backends.
Stars: ✭ 106 (-3.64%)
Mutual labels:  database
Php Thrift Sql
A PHP library for connecting to Hive or Impala over Thrift
Stars: ✭ 107 (-2.73%)
Mutual labels:  database
Gkvdb
[mirror] Go语言开发的基于DRH(Deep-Re-Hash)深度哈希分区算法的高性能高可用Key-Value嵌入式事务数据库。基于纯Go语言实现,具有优异的跨平台性,良好的高可用及文件IO复用设计,高效的底层数据库文件操作性能,支持原子操作、批量操作、事务操作、多表操作、多表事务、随机遍历等特性。
Stars: ✭ 109 (-0.91%)
Mutual labels:  database
Next
Directus is a real-time API and App dashboard for managing SQL database content. 🐰
Stars: ✭ 111 (+0.91%)
Mutual labels:  database
Slightphp
SlightPHP 高效的PHP敏捷开发框架
Stars: ✭ 110 (+0%)
Mutual labels:  database

Gungnir

A fully featured, data-driven database library for Clojure.

Build Status codecov Dependencies Status Clojars Project Slack

It is said that Gungnir could strike any target, regardless of the wielder's skill.

- Developer, speaking to the database admin.

Read the guide

Dutch Clojure Meetup - Gungnir

(gungnir.database/make-datasource!
  {:adapter       "postgresql"
   :username      "postgres"
   :password      "postgres"
   :database-name "postgres"
   :server-name   "localhost"
   :port-number   5432})

(def user-model
  [:map
   [:user/id {:primary-key true} uuid?]
   [:user/email {:before-save [:string/lower-case]
                 :before-read [:string/lower-case]}
    [:re {:error/message "Invalid email"} #"[email protected]+\..+"]]
   [:user/password {:before-save [:bcrypt]} [:string {:min 6}]]
   [:user/password-confirmation {:virtual true} [:string {:min 6}]]
   [:user/created-at {:auto true} inst?]
   [:user/updated-at {:auto true} inst?]])

(gungnir.model/register!
 {:user user-model})

(defn password-match? [m]
  (= (:user/password m)
     (:user/password-confirmation m)))

(defmethod gungnir.model/validator :user/password-match? [_]
  {:validator/key :user/password-confirmation
   :validator/fn password-match?
   :validator/message "Passwords don't match"})

(defmethod gungnir.model/before-save :bcrypt [_k v]
  (buddy.hashers/derive v))

(defn attempt-register-user [request]
  (-> (:form-params request)
      (gungnir.changeset/cast :user)
      (gungnir.changeset/create [:user/password-match?])
      (gungnir.query/save!)))

(comment
  (gungnir.query/find-by! :user/email "[email protected]") ;; => {:user/email "[email protected]",,,}
  (-> (gungnir.query/limit 5)
      (gungnir.query/select :user/id :user/email)
      (gungnir.query/all! :user)) ;; => [{:user/email "..." :user/id "..."},,,]
  )

Installation

Gungnir is still in its design phase and can result in breaking changes while on the SNAPSHOT version. Any breaking changes will be reflected in the updated documentation.

Add the following dependencies to your project.clj

Versions

:dependencies [[kwrooijen/gungnir "0.0.1-xxxxxxxx.yyyyyy-z"]
               ;; Optionally for frontend validation
               [kwrooijen/gungnir.ui "0.0.1-xxxxxxxx.yyyyyy-z"]
               ,,,]

Rationale

Plug & Play setup with quality of life

The Clojure community tends to lean towards the "pick the libraries that you need" method rather than using a "framework" when building an application. This can make it challenging for new users. Once you're familiar with the Clojure ecosystem you'll know which libraries you prefer and create your own setup. And that's exactly what I've done.

If you want complete control over your database stack, then this is probably not for you. If you're a beginner and are overwhelmed with all the necessary libraries and configuration, or if you're looking for a Clojure database library that aims to provide a quality of life experience similar to Ruby's ActiveRecord or Elixir's Ecto, then stick around.

Data Driven

I cannot stress this enough, I really dislike macros. Clojure and a large part of it's community have taught me the beauty of writing data driven code. With great libraries such as HoneySQL, Hiccup, Integrant, Reitit, Malli, I think this is the Golden age of Data Driven Clojure. I never want to see macros in my API again.

Features

Plug & Play™

Include Gungnir in your project, and off you go! Gungnir includes everything for your database needs.

Models

Gungnir uses models to provide data validation and seamless translation between Clojure and SQL. Read more

Changesets

Inspired by Elixir Ecto's Changesets. Validate your data before inserting or updating it in your database. View the actual changes being made, and aggregate any error messages. Read more

Querying & Extension to HoneySQL

Gungnir isn't here to reinvent the wheel. Even though we have an interface for querying the database, we can still make use of HoneySQL syntax. This allows us to expand our queries, or write more complex ones for the edge cases. Read more

Migrations

Define your migrations using Clojure data structures and extend them as needed. You can also fallback to raw SQL if necessary. Read more

Relational mapping

Relations are easily accessed with Gungnir. Records with relations will have access to relational atoms which can be dereffed to query any related rows. Read more, and more

Frontend validation

Gungnir also provides an extra package, gungnir.ui. Which provides some validation in the frontend. Read more

Resources

Guide

Read the guide for a full overview of all the features and how to use them.

Code Playground

The Gungnir code playground is a repository with an "interactive tutorial". Clone the repository and execute the code in the core namespace step by step.

Developing

Testing

In order to run the tests you'll need docker-compose. Make sure this is an up to date version. Inside of the root directory you can setup the testing databases with the following command.

docker-compose up -d

Then run the tests with lein

lein test

Author / License

Released under the MIT License by Kevin William van Rooijen.

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].