Giter Club home page Giter Club logo

jiranium's Introduction

Jiranium

A set of reusable components we use in our scala programs.

Installation

Add this to your SBT config:

// resolver
val jirafeSnaps = "jirafe.com" at "https://raw.github.com/jirafe/mvn-repo/master/releases"

// dependency
val jiraniumAnorm = "com.jirafe" %% "jiranium-anorm" % "1.0"

Play2 utilities

Anorm

Sql parsers

import jiranium.anorm.SqlParsers._

val mapping =
  optInt("my_table.plan_id") ~ // parses an Option[Int]
  dateTime("my_table.created_t_stamp") // parses a joda.org.time.DateTime

See more parsers at play/src/main/scala/SqlParser.scala

Query utilities

Query.insert

import jiranium.anorm.Query

// insert in my_table
Query.insert("my_table")('foo -> "omg", 'bar -> "ponies!!").execute()

// is equivalent to:
SQL("""insert into %s (foo, bar) values ({foo}, {bar})""" format "my_table")
.on('foo -> "omg", 'bar -> "ponies!!")
.execute()

It also supports type cast

Query.insert("my_table") {
  'user_id -> "::uuid" -> userId,
  'offset -> "* '1s'::interval" -> offset
}

Query.timestamp

Query.timestamp(dateTime: DateTime): java.sql.Timestamp

Implicits

import jiranium.anorm.implicits._

// String.formatSql
"select a.omg, b.ponies from %s a, %s b".formatSql("table1", "table2")

// is equivalent to:
SQL("select a.omg, b.ponies from %s a, %s b".format("table1", "table2"))

How to publish to jirafe/mvn-repo

This section is intended to Jirafe developers. First of all, increment the version number in project/Build.scala. Then publish and push to github mvn-repo:

sbt publish
cd /path/to/mvn-repo
cp -r ~/.m2/repository/releases/com/jirafe/jiranium-anorm_2.9.1/* releases/com/jirafe/jiranium-anorm_2.9.1/
git add releases/com/jirafe/jiranium-anorm_2.9.1/
git commit -m "publish jiranium"
git push
cd -

jiranium's People

Contributors

ornicar avatar jlcanela avatar

Stargazers

 avatar

Watchers

James Cloos avatar

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.