8000 GitHub - justinwoo/purescript-chanpon: Fancy record-based queries for my node-sqlite3 library
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

justinwoo/purescript-chanpon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PureScript Chanpon

Build Status

Fancy record-based queries for my node-sqlite3 library.

Example

From test/Main.purs

main :: _
main = runTest do
  suite "Chanpon" do
    test "Works as expected" do
      _ <- attempt $ FS.unlink testDB
      db <- newDB testDB
      C.createTableIfNotExists table db
        { name: "text primary key unique"
        , whatever: "text"
        }
      C.insertOrReplaceInto table db
        { name: "hello"
        , whatever: "world"
        }
      namesOnly
         <- sequence
        <$> C.selectAll table db
              (Proxy :: Proxy { name :: String })
      withWhatever
         <- sequence
        <$> C.selectAll table db
              (Proxy :: Proxy { name :: String, whatever :: String })
      case runExcept $ Tuple <$> namesOnly <*> withWhatever of
        Right (Tuple [l] [r]) -> do
          Assert.assert "expected value from names" $ l.name == "hello"
          Assert.assert "expected value from withWhatever" $ l.name == "hello"
          Assert.assert "expected value from withWhatever" $ r.whatever == "world"
        Right a -> do
          failure $ "incorrect results: " <> unsafeCoerce a
        Left e -> do
          failure $ show e
      C.deleteFrom table db { name: "hello" }
      result <- C.selectAll table db (Proxy :: Proxy { name :: String })
      Assert.assert "table is empty after deleting" $ Array.length result == 0
  where
    testDB = "./test/test.db"
    table = C.Table "test"

About

Fancy record-based queries for my node-sqlite3 library

Resources

License

Stars

Watchers

Forks

Packages

No packages published
0