Commit 0
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using GameAuthApi.Models;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using MongoDB.Driver;
|
||||
|
||||
namespace GameAuthApi.Services;
|
||||
|
||||
public class SpawnableService
|
||||
{
|
||||
private readonly IMongoCollection<Spawnable> _spawnables;
|
||||
|
||||
public SpawnableService(IConfiguration config)
|
||||
{
|
||||
var client = new MongoClient(config["MongoDB:ConnectionString"]);
|
||||
var db = client.GetDatabase(config["MongoDB:DatabaseName"]);
|
||||
_spawnables = db.GetCollection<Spawnable>("Spawnables");
|
||||
}
|
||||
|
||||
public async Task CreateAsync(Spawnable spawnable)
|
||||
{
|
||||
await _spawnables.InsertOneAsync(spawnable);
|
||||
}
|
||||
|
||||
public async Task<List<Spawnable>> GetAllAsync()
|
||||
{
|
||||
return await _spawnables.Find(_ => true).ToListAsync();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user