Coder Social home page Coder Social logo

mql's Introduction

Inspired by http://github.com/MrHus/rql

What is mql

mql is clojure library to query map data structures

Usage

Given a map

(def m {:cid { :visits { :id-1 { :last-ts "1284166000040" :first-ts "1274166000000" :duration "40"} :id-2 { :last-ts "1274166000040" :first-ts "1274166000000" :duration "40"} :id-3 { :last-ts "1264166000040" :first-ts "1274166000000" :duration "40"}}

   :promo{
          :id-1 {:promo "p2"}
          :id-2 {:promo "p1"}}
   
   :purchase {
              :id-1
              {:order-id "order-id-1"
               :total-dollars "970.00"
               :purchase? "true",
               :merchant-total-dollars "1000.00"}
              :id-3
              {:order-id "order-id-2"
               :total-dollars "1000.00"
               :purchase? ""
               :merchant-total-dollars "1000.00"}}}})

Select: simple select

       (select [:cid :promo] m)  

will return

       {:id-1 {:promo "p2"} :id-2 {:promo "p1"}} 

Select: with filtering

      (select [:cid :purchase] (where [* :total-dollars] :gt 980) m) 

will return

      {:id-1
          {:order-id "order-id-1"
           :total-dollars "970.00"
           :purchase? "true",
           :merchant-total-dollars "1000.00"}}

You can use :gt, :lt, :ge, :le and :eq as logical operator in where clause. In where clause for key-seq you can use * if a key is dynamic. The last key in where clause key-seq should not be *.

Limitations:

  • There could be only one * in Where Clause
  • Select clause cannot have * now

License

Copyright (C) 2010 Siva Jagadeesan

Distributed under the Eclipse Public License, the same as Clojure.

mql's People

Contributors

sivajag avatar

Stargazers

Gary Fenstamaker avatar Christopher Thomas Davies avatar Don Jackson avatar Terje Sten Bjerkseth avatar Alex Petrov avatar Andrés Gu avatar Kasper Langer avatar Val Packett avatar Shane Daniel avatar Sergio Bossa avatar Eric avatar Nurullah Akkaya avatar  avatar edwardt avatar Jack Moffitt avatar Robert J. Berger avatar  avatar

Watchers

 avatar James Cloos avatar

Forkers

rberger dcj tranchis

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.