From 973fb2c5371bb6d4a409e11bec632b9d67b2c25d Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Thu, 2 Jan 2020 13:24:00 +0200 Subject: [PATCH] fsharp(todolist-api): feat: added a working SqlTypeProvider Signed-off-by: prescientmoon --- fsharp/todolist-api/paket.dependencies | 4 +- fsharp/todolist-api/paket.lock | 117 ++++++++++++++++++++++++ fsharp/todolist-api/paket.references | 2 + fsharp/todolist-api/src/Db.fs | 12 +++ fsharp/todolist-api/suaveTodoApi.fsproj | 1 + 5 files changed, 135 insertions(+), 1 deletion(-) create mode 100644 fsharp/todolist-api/src/Db.fs diff --git a/fsharp/todolist-api/paket.dependencies b/fsharp/todolist-api/paket.dependencies index 0257c92..e5fd088 100644 --- a/fsharp/todolist-api/paket.dependencies +++ b/fsharp/todolist-api/paket.dependencies @@ -4,4 +4,6 @@ storage: none framework: netcore3.1 nuget FSharp.Core -nuget Suave \ No newline at end of file +nuget Suave +nuget SQLProvider +nuget Npgsql \ No newline at end of file diff --git a/fsharp/todolist-api/paket.lock b/fsharp/todolist-api/paket.lock index 5a10f7a..2e06b1b 100644 --- a/fsharp/todolist-api/paket.lock +++ b/fsharp/todolist-api/paket.lock @@ -3,5 +3,122 @@ RESTRICTION: == netcoreapp3.1 NUGET remote: https://api.nuget.org/v3/index.json FSharp.Core (4.7) + Microsoft.NETCore.Platforms (3.1) + Microsoft.NETCore.Targets (3.1) + Microsoft.Win32.Registry (4.7) + System.Security.AccessControl (>= 4.7) + System.Security.Principal.Windows (>= 4.7) + NETStandard.Library (2.0.3) + Microsoft.NETCore.Platforms (>= 1.1) + Npgsql (4.1.2) + System.Runtime.CompilerServices.Unsafe (>= 4.6) + runtime.native.System.Data.SqlClient.sni (4.7) + runtime.win-arm64.runtime.native.System.Data.SqlClient.sni (>= 4.4) + runtime.win-x64.runtime.native.System.Data.SqlClient.sni (>= 4.4) + runtime.win-x86.runtime.native.System.Data.SqlClient.sni (>= 4.4) + runtime.win-arm64.runtime.native.System.Data.SqlClient.sni (4.4) + runtime.win-x64.runtime.native.System.Data.SqlClient.sni (4.4) + runtime.win-x86.runtime.native.System.Data.SqlClient.sni (4.4) + SQLProvider (1.1.76) + FSharp.Core (>= 3.1.2.5) + NETStandard.Library (>= 2.0) + System.Console (>= 4.3) + System.Data.Common (>= 4.3) + System.Data.Odbc (>= 4.5) + System.Data.SqlClient (>= 4.4) + System.IO (>= 4.3) + System.Reflection (>= 4.3) + System.Reflection.TypeExtensions (>= 4.3) + System.Runtime (>= 4.3) + System.Runtime.Loader (>= 4.3) + System.Runtime.Serialization.Formatters (>= 4.3) + System.Runtime.Serialization.Primitives (>= 4.3) Suave (2.5.6) FSharp.Core (>= 4.3.4) + System.Collections (4.3) + Microsoft.NETCore.Platforms (>= 1.1) + Microsoft.NETCore.Targets (>= 1.1) + System.Runtime (>= 4.3) + System.Console (4.3.1) + Microsoft.NETCore.Platforms (>= 1.1) + Microsoft.NETCore.Targets (>= 1.1.2) + System.IO (>= 4.3) + System.Runtime (>= 4.3) + System.Text.Encoding (>= 4.3) + System.Data.Common (4.3) + System.Collections (>= 4.3) + System.Globalization (>= 4.3) + System.IO (>= 4.3) + System.Resources.ResourceManager (>= 4.3) + System.Runtime (>= 4.3) + System.Runtime.Extensions (>= 4.3) + System.Text.RegularExpressions (>= 4.3) + System.Threading.Tasks (>= 4.3) + System.Data.Odbc (4.7) + Microsoft.NETCore.Platforms (>= 3.1) + System.Data.SqlClient (4.8) + Microsoft.Win32.Registry (>= 4.7) + runtime.native.System.Data.SqlClient.sni (>= 4.7) + System.Security.Principal.Windows (>= 4.7) + System.Globalization (4.3) + Microsoft.NETCore.Platforms (>= 1.1) + Microsoft.NETCore.Targets (>= 1.1) + System.Runtime (>= 4.3) + System.IO (4.3) + Microsoft.NETCore.Platforms (>= 1.1) + Microsoft.NETCore.Targets (>= 1.1) + System.Runtime (>= 4.3) + System.Text.Encoding (>= 4.3) + System.Threading.Tasks (>= 4.3) + System.Reflection (4.3) + Microsoft.NETCore.Platforms (>= 1.1) + Microsoft.NETCore.Targets (>= 1.1) + System.IO (>= 4.3) + System.Reflection.Primitives (>= 4.3) + System.Runtime (>= 4.3) + System.Reflection.Primitives (4.3) + Microsoft.NETCore.Platforms (>= 1.1) + Microsoft.NETCore.Targets (>= 1.1) + System.Runtime (>= 4.3) + System.Reflection.TypeExtensions (4.7) + System.Resources.ResourceManager (4.3) + Microsoft.NETCore.Platforms (>= 1.1) + Microsoft.NETCore.Targets (>= 1.1) + System.Globalization (>= 4.3) + System.Reflection (>= 4.3) + System.Runtime (>= 4.3) + System.Runtime (4.3.1) + Microsoft.NETCore.Platforms (>= 1.1.1) + Microsoft.NETCore.Targets (>= 1.1.3) + System.Runtime.CompilerServices.Unsafe (4.7) + System.Runtime.Extensions (4.3.1) + Microsoft.NETCore.Platforms (>= 1.1.1) + Microsoft.NETCore.Targets (>= 1.1.3) + System.Runtime (>= 4.3.1) + System.Runtime.Loader (4.3) + System.IO (>= 4.3) + System.Reflection (>= 4.3) + System.Runtime (>= 4.3) + System.Runtime.Serialization.Formatters (4.3) + System.Collections (>= 4.3) + System.Reflection (>= 4.3) + System.Resources.ResourceManager (>= 4.3) + System.Runtime (>= 4.3) + System.Runtime.Serialization.Primitives (>= 4.3) + System.Runtime.Serialization.Primitives (4.3) + System.Resources.ResourceManager (>= 4.3) + System.Runtime (>= 4.3) + System.Security.AccessControl (4.7) + Microsoft.NETCore.Platforms (>= 3.1) + System.Security.Principal.Windows (>= 4.7) + System.Security.Principal.Windows (4.7) + System.Text.Encoding (4.3) + Microsoft.NETCore.Platforms (>= 1.1) + Microsoft.NETCore.Targets (>= 1.1) + System.Runtime (>= 4.3) + System.Text.RegularExpressions (4.3.1) + System.Runtime (>= 4.3.1) + System.Threading.Tasks (4.3) + Microsoft.NETCore.Platforms (>= 1.1) + Microsoft.NETCore.Targets (>= 1.1) + System.Runtime (>= 4.3) diff --git a/fsharp/todolist-api/paket.references b/fsharp/todolist-api/paket.references index 787e922..b5c75be 100644 --- a/fsharp/todolist-api/paket.references +++ b/fsharp/todolist-api/paket.references @@ -1,2 +1,4 @@ FSharp.Core Suave +nuget SQLProvider +nuget Npgsql \ No newline at end of file diff --git a/fsharp/todolist-api/src/Db.fs b/fsharp/todolist-api/src/Db.fs new file mode 100644 index 0000000..e3a7799 --- /dev/null +++ b/fsharp/todolist-api/src/Db.fs @@ -0,0 +1,12 @@ +module Db + +open FSharp.Data.Sql + +[] +let ConnectionString = "Server=127.0.0.1; Database=todo_api_db; User Id=suave; Password=1234;" + +type Sql = SqlDataProvider + +type DbContext = Sql.dataContext + +type Todo = DbContext.``public.todosEntity`` diff --git a/fsharp/todolist-api/suaveTodoApi.fsproj b/fsharp/todolist-api/suaveTodoApi.fsproj index f62ef0f..d49796c 100644 --- a/fsharp/todolist-api/suaveTodoApi.fsproj +++ b/fsharp/todolist-api/suaveTodoApi.fsproj @@ -5,6 +5,7 @@ netcoreapp3.1 +