Table of Contents

Database

As of this writing, Pillars only supports MongoDB database, using the data access library MongoDB.Entities. The goal is to provide a simple, frictionless and easy-to-use experience, which excludes Schema Migrations and the need to maintain them.

Please refer to the MongoDB.Entities documentation to get a better understanding.

Configuration

The database configuration can be changed in the mongosettings.json

Entities

Pillars comes with several Entities already included. An Entity defines the structure of a database collection, see here.

Warning

For easier reference and extending of entities, it is recommended to have a common namespace Pillars.Entities across all entities.

Example:

namespace Pillars.Entities;

[Collection("accounts")]
public sealed partial class Account : Entity, ICreatedOn, IModifiedOn
{
	public ulong DiscordId { get; set; }

	public DateTime CreatedOn { get; set; }

	public DateTime ModifiedOn { get; set; }
}

Extending / Embedding Entities

To add additional fields to an existing Entity, a partial class is preferred.

The following examples adds a LastLogin field to the Account , using the IgnoreDefault mechanism, so null values don't get saved. The implementation is done in the corresponding controller.

Tip

When extending / embedding entities, please also refer to Entity Relationships.

namespace Pillars.Entities;

public sealed partial class Account
{
	[IgnoreDefault]
	public DateTime? LastLogin { get; set; }
}