Table of Contents

Interface IUserRepository<TUserEntity>

Namespace
Tharga.Team.MongoDB
Assembly
Tharga.Team.MongoDB.dll
public interface IUserRepository<TUserEntity> : IRepository where TUserEntity : EntityBase, IUser

Type Parameters

TUserEntity

Methods

AddAsync(TUserEntity)

Task AddAsync(TUserEntity user)

Parameters

user TUserEntity

Returns

Task

DeleteAsync(string)

Deletes the user document.

Task DeleteAsync(string userKey)

Parameters

userKey string

Returns

Task

Remarks

Declared with a default implementation so existing custom repositories keep compiling. The default throws rather than no-opping: silently skipping a requested deletion would hide the missing implementation behind an apparently successful call.

GetAsync()

IAsyncEnumerable<TUserEntity> GetAsync()

Returns

IAsyncEnumerable<TUserEntity>

GetAsync(string)

Task<TUserEntity> GetAsync(string identity)

Parameters

identity string

Returns

Task<TUserEntity>

GetByEMailAsync(string)

Every user whose EMail is email, compared trimmed and ignoring case; empty for a blank address.

Task<TUserEntity[]> GetByEMailAsync(string email)

Parameters

email string

Returns

Task<TUserEntity[]>

Remarks

Every match, not the first. Nothing makes an address unique — the built-in collection indexes only Identity — and a caller deciding whose mail this is has to know when two accounts claim it.

A default interface method that reads every user, so a host's own repository keeps compiling and answers correctly, if slowly; the built-in one asks the database.

GetByKeyAsync(string)

Task<TUserEntity> GetByKeyAsync(string userKey)

Parameters

userKey string

Returns

Task<TUserEntity>

GetByKeysAsync(IReadOnlyCollection<string>)

The users with these keys, each once; a key no user has is left out.

Task<TUserEntity[]> GetByKeysAsync(IReadOnlyCollection<string> userKeys)

Parameters

userKeys IReadOnlyCollection<string>

Returns

Task<TUserEntity[]>

Remarks

A default interface method that asks for one key at a time, so a host's own repository keeps compiling; the built-in one asks the database once.

SearchAsync(string)

The users whose name or address holds text, ignoring case, that are not disabled, as they are read; nothing for empty text.

IAsyncEnumerable<TUserEntity> SearchAsync(string text)

Parameters

text string

Returns

IAsyncEnumerable<TUserEntity>

Remarks

A stream, so a caller filtering further stops reading when it has enough. A default interface method that reads every user, so a host's own repository keeps compiling and answers correctly, if slowly; the built-in one asks the database.

SetDirectoryIdAsync(string, string)

Sets DirectoryId on the user document. Same opt-in-by-entity-shape contract as SetLastSeenAsync(string, DateTime): a no-op unless the entity declares a DirectoryId property.

Task SetDirectoryIdAsync(string userKey, string directoryId)

Parameters

userKey string
directoryId string

Returns

Task

SetEMailAsync(string, string)

Sets EMail on the user document.

Task SetEMailAsync(string userKey, string email)

Parameters

userKey string
email string

Returns

Task

Remarks

Declared with a default implementation so existing custom repositories keep compiling. The default throws rather than no-opping, for the reason DeleteAsync(string) gives: an address that was asked to change and silently did not is a missing implementation dressed as success.

SetIconAsync(string, string)

Sets Icon (the icon reference) on the user document. Same opt-in-by-entity-shape contract as SetDirectoryIdAsync(string, string): a no-op unless the entity declares an Icon property.

Task SetIconAsync(string userKey, string reference)

Parameters

userKey string
reference string

Returns

Task

SetLastSeenAsync(string, DateTime)

Stamps LastSeen on the user document. Called automatically by the throttled resolve path, so the default (and the built-in repository, when TUserEntity does not declare a LastSeen property) is a no-op — activity tracking is opted into by declaring the property on the entity.

Task SetLastSeenAsync(string userKey, DateTime lastSeen)

Parameters

userKey string
lastSeen DateTime

Returns

Task

SetNameAsync(string, string)

Task SetNameAsync(string userKey, string name)

Parameters

userKey string
name string

Returns

Task