GithubHelp home page GithubHelp logo

dataprism's Introduction

DataPrism

A new FRM with focus on Higher Kinded Data

DataPrism is an SQL query construction library built to take full advantage of the power of higher kinded data. DataPrism builds on perspective and the tools it provides for programming with higher kinded data.

The power of higher kinded data makes DataPrism more flexible than other Scala SQL libraries. Want to sometimes leave out a column? You can do that. Want to return a List from a query? Sure thing.

DataPrism works with both Java's JDBC and Skunk.

Add DataPrism to your project by adding these statements to your build.sbt file:

// For JDBC
libraryDependencies += "net.katsstuff" %% "dataprism-jdbc" % "{{versions.dataprism}}"

// For Skunk
libraryDependencies += "net.katsstuff" %% "dataprism-skunk" % "{{versions.dataprism}}"

DataPrism is currently early in development, but feel free to try it out and report bugs and errors.

Showcase

See the docs for a full explanation and walkthrough.

case class HomeK[F[_]](
  owner: F[UUID],
  name: F[String],
  createdAt: F[Instant],
  updatedAt: F[Instant],
  x: F[Double],
  y: F[Double],
  z: F[Double],
  yaw: F[Float],
  pitch: F[Float],
  worldUuid: F[UUID]
)

object HomeK {
  import dataprism.jdbc.sql.JdbcType
  import dataprism.jdbc.sql.PostgresJdbcTypes.*
  val table: Table[HomeK, JdbcType] = Table(
    "homes",
    HomeK(
      owner = Column("owner", uuid),
      name = Column("name", text),
      createdAt = Column("created_at", javaTime.timestamptz),
      updatedAt = Column("updated_at", javaTime.timestamptz),
      x = Column("x", doublePrecision),
      y = Column("y", doublePrecision),
      z = Column("z", doublePrecision),
      yaw = Column("yaw", real),
      pitch = Column("pitch", real),
      worldUuid = Column("world_uuid", uuid)
    )
  )

  given KMacros.ApplyTraverseKC[HomeK] = KMacros.deriveApplyTraverseKC[HomeK]
}


Query.from(HomeK.table).map(homes => (homes.owner, homes.name))

Query
  .from(HomeK.table)
  .groupBy(homes => (homes.owner, homes.name))((grouped, homes) =>
    (
      grouped._1,
      grouped._2,
      homes.x.arrayAgg,
      homes.y.arrayAgg,
      homes.z.arrayAgg
    )
  )

dataprism's People

Contributors

darichey avatar katrix avatar

Watchers

 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.