Skip to content

Commit

Permalink
feat(lyra): adds "default language" configuration in class initializer
Browse files Browse the repository at this point in the history
  • Loading branch information
micheleriva committed Jun 11, 2022
1 parent 1bc4217 commit c12aec4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/lyra/src/lyra.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export type PropertiesSchema = {

export type LyraProperties = {
schema: PropertiesSchema;
defaultLanguage?: Language;
};

export type LyraDocs = Map<string, object>;
Expand All @@ -41,6 +42,7 @@ type SearchResult = Promise<{
}>;

export class Lyra {
private defaultLanguage: Language = "english";
private schema: PropertiesSchema;
private docs: LyraDocs = new Map();
private index: LyraIndex = new Map();
Expand All @@ -51,6 +53,7 @@ export class Lyra {
);

constructor(properties: LyraProperties) {
this.defaultLanguage = properties.defaultLanguage || "english";
this.schema = properties.schema;
this.buildIndex(properties.schema);
}
Expand Down Expand Up @@ -187,7 +190,7 @@ export class Lyra {

public async insert(
doc: object,
language: Language = "english"
language: Language = this.defaultLanguage
): Promise<{ id: string }> {
const id = nanoid();

Expand Down

0 comments on commit c12aec4

Please sign in to comment.