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 _spawnables; public SpawnableService(IConfiguration config) { var client = new MongoClient(config["MongoDB:ConnectionString"]); var db = client.GetDatabase(config["MongoDB:DatabaseName"]); _spawnables = db.GetCollection("Spawnables"); } public async Task CreateAsync(Spawnable spawnable) { await _spawnables.InsertOneAsync(spawnable); } public async Task> GetAllAsync() { return await _spawnables.Find(_ => true).ToListAsync(); } }