Skip to content

Commit

Permalink
some changes to types after a quick review
Browse files Browse the repository at this point in the history
  • Loading branch information
guyroyse committed Dec 23, 2021
1 parent 8e43a20 commit 80a8574
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/entity/entity.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* A JavaScript object containing the underlying data of an {@link Entity}.
*/
export type EntityData = { [key: string]: string | number | boolean | string[] };
export type EntityData = Record<string, number | boolean | string | string[]>;

/**
* A constructor that creates an {@link Entity} of type TEntity.
Expand Down
8 changes: 4 additions & 4 deletions lib/repository/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export default class Repository<TEntity extends Entity> {
* @param data Optional values with which to initialize the entity.
* @returns A newly created Entity.
*/
createEntity(data: Record<string, any> = {}): TEntity {
createEntity(data: EntityData = {}): TEntity {
let id = this.schema.generateId();
let entity = new this.schema.entityCtor(id);
for (let key in data) {
Expand Down Expand Up @@ -142,12 +142,12 @@ export default class Repository<TEntity extends Entity> {
}

/**
* Creates and saves an {@link Entity}. Equivalent of calling {@link Entity.createEntity}
* followed by {@link Entity.save}.
* Creates and saves an {@link Entity}. Equivalent of calling
* {@link Repository.createEntity} followed by {@link Repository.save}.
* @param data Optional values with which to initialize the entity.
* @returns The newly created and saved Entity.
*/
async createAndSave(data: Record<string, any> = {}): Promise<TEntity> {
async createAndSave(data: EntityData = {}): Promise<TEntity> {
let entity = this.createEntity(data);
await this.save(entity)
return entity
Expand Down

0 comments on commit 80a8574

Please sign in to comment.