A port of juspay/purescript-sequelize into Haskell, mimicking Sequelize.js v4.
Has not been tried in production yet.
Does not provide INSERT or DELETE yet.
Define a Beam table:
dataTestTf=Test{email::B.ColumnarfText,
enabled::B.Columnar (B.Nullablef) Bool}deriving (Generic)
typeTest=TestTIdentityinstanceB.BeamableTestTinstanceB.TableTestTwheredataPrimaryKeyTestTf=TestId (B.ColumnarfText) deriving (Generic, B.Beamable)
primaryKey =TestId. emailDefine a ModelMeta instance. You can modify table properties here.
instanceModelMetaTestTwhere
modelFieldModification =B.tableModification
modelTableName ="test"Simple SELECT:
{-# LANGUAGE OverloadedLabels #-}
importNamedgetDisabled::SqlSelectMySQLTest
getDisabled =
sqlSelect
!#where_ [Is enabled Null]
! defaultsA more complex SELECT:
{-# LANGUAGE OverloadedLabels #-}
importNamedgetSpecificPeople::SqlSelectMySQLTest
getSpecificPeople =
sqlSelect
!#where_
[ Is enabled (NotNull),
Or [Is email (Eq"a@example.com"), Is email (Eq"b@example.com")]
]
!#orderBy [Asc enabled, Desc email]
!#offset 8!#limit 10Set some fields:
{-# LANGUAGE OverloadedLabels #-}
importNamedbusted::SqlUpdateMySQLTestT
busted =
sqlUpdate
!#set [Set enabled Nothing]
!#where_ [Is enabled (NotNull)]Set all fields:
{-# LANGUAGE OverloadedLabels #-}
importNameddisableSomeone::SqlUpdateMySQLTestT
disableSomeone =
sqlUpdate'
!#save (Test"a@example.com" (JustFalse))
!#where_ [Is email (Eq"a@example.com")]We support Set and SetDefault.
Nix:
$ nix-shell
(nix-shell) $ cabal build
(nix-shell) $ cabal testStack:
$ stack build
$ stack teststack test doesn't work, because stack does not able to set lenient flag for cabal.
Use cabal tests instead.
Be sure the repo has cabal.project.local with packages: ../beam-mysql inside. Then run euler dev and then cabal test -f lenient