mirror of
https://github.com/BarkProductions/barkman.git
synced 2026-06-13 06:11:55 +00:00
Switch to PostgreSQL and update database configuration
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using barkmanapi;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.OpenApi.Models;
|
||||
|
||||
@@ -20,6 +21,9 @@ builder.Services.AddCors(options =>
|
||||
policy.WithOrigins("https://barkdev.ts.drewr.io", "http://localhost:5173").AllowAnyMethod().AllowAnyHeader();
|
||||
});
|
||||
});
|
||||
builder.Services.AddDbContext<BarkContext>(opt =>
|
||||
opt.UseNpgsql(builder.Configuration.GetConnectionString("DefaultConnection")).UseSnakeCaseNamingConvention());
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
if (!app.Environment.IsProduction())
|
||||
@@ -34,7 +38,7 @@ if (!app.Environment.IsProduction())
|
||||
app.MapGet("/", () => "Hello World!");
|
||||
|
||||
app.MapGet("/inventory", async (BarkContext db) =>
|
||||
await db.Inventory.ToListAsync());
|
||||
await db.Inventory.OrderBy(item=>item.Id).ToListAsync());
|
||||
|
||||
app.MapGet("/inventory/{id}", async (int id, BarkContext db) =>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user