Skip to content

web-backend


Class: FmeaService ​

Defined in: packages/web-backend/src/fmea/fmea.service.ts:13

Service layer for FMEA business logic and persistence. Supports CRUD operations on FMEA columns, rows, and cells.

Constructors ​

Constructor ​

new FmeaService(fmeaModel, ModelCounterModel): FmeaService

Defined in: packages/web-backend/src/fmea/fmea.service.ts:19

Parameters ​

fmeaModel ​

Model<FmeaDocument>

Mongoose model for FMEA documents.

ModelCounterModel ​

Model<ModelCounterDocument>

Mongoose model for sequence counters.

Returns ​

FmeaService

Methods ​

addColumn() ​

addColumn(fmeaId, body): Promise<Fmea>

Defined in: packages/web-backend/src/fmea/fmea.service.ts:102

Add a column to the FMEA. If the column type is "string" then dropdown options are empty; if it is "dropdown" then options are populated.

Parameters ​

fmeaId ​

number

FMEA ID to add the column to

body ​

any

Contains new column name, type, and dropdown options

Returns ​

Promise<Fmea>

The updated FMEA


addRow() ​

addRow(fmeaId): Promise<Fmea>

Defined in: packages/web-backend/src/fmea/fmea.service.ts:140

Add a new row to the FMEA. For columns of type string the value is initialized as empty string, and for dropdown columns it is set to the first option.

Parameters ​

fmeaId ​

number

The ID of the FMEA to update

Returns ​

Promise<Fmea>

The FMEA with the added row


createFmea() ​

createFmea(body): Promise<Fmea>

Defined in: packages/web-backend/src/fmea/fmea.service.ts:61

Create a new FMEA.

Parameters ​

body ​

any

Contains title and description

Returns ​

Promise<Fmea>

The created FMEA object


deleteColumn() ​

deleteColumn(fmeaId, column): Promise<Fmea>

Defined in: packages/web-backend/src/fmea/fmea.service.ts:272

Delete a column from an FMEA.

Parameters ​

fmeaId ​

number

The FMEA ID

column ​

string

The column to be deleted

Returns ​

Promise<Fmea>

Updated FMEA object


deleteFmea() ​

deleteFmea(id): Promise<boolean>

Defined in: packages/web-backend/src/fmea/fmea.service.ts:260

Delete an FMEA by ID.

Parameters ​

id ​

number

The FMEA ID

Returns ​

Promise<boolean>

True if the FMEA was deleted; otherwise false


deleteRow() ​

deleteRow(fmeaId, rowId): Promise<Fmea>

Defined in: packages/web-backend/src/fmea/fmea.service.ts:291

Delete a row from an FMEA.

Parameters ​

fmeaId ​

number

The FMEA ID

rowId ​

The row ID to be deleted

string | number

Returns ​

Promise<Fmea>

Updated FMEA object


getFmeaById() ​

getFmeaById(id): Promise<Fmea>

Defined in: packages/web-backend/src/fmea/fmea.service.ts:81

Get an FMEA by ID.

Parameters ​

id ​

number

The unique ID for the FMEA

Returns ​

Promise<Fmea>

The FMEA found


getNextValue() ​

getNextValue(name): Promise<number>

Defined in: packages/web-backend/src/fmea/fmea.service.ts:33

Create or increment a named counter. Generates an ID for the newly created user in an incremental order of 1. Initially if no model exists, the serial ID starts from 1.

Parameters ​

name ​

string

Name of the counter

Returns ​

Promise<number>

ID number


getNumberOfFmea() ​

getNumberOfFmea(): Promise<number>

Defined in: packages/web-backend/src/fmea/fmea.service.ts:90

Get the number of FMEAs in the database.

Returns ​

Promise<number>

Number of FMEAs in the database


getValue() ​

getValue(name): Promise<number>

Defined in: packages/web-backend/src/fmea/fmea.service.ts:50

Read the current value of a named counter. Generates an ID for the newly created user in an incremental order of 1. Initially if no user exists, the serial ID starts from 1.

Parameters ​

name ​

string

Name of the counter

Returns ​

Promise<number>

ID number


updateCell() ​

updateCell(fmeaId, rowId, column, value): Promise<boolean>

Defined in: packages/web-backend/src/fmea/fmea.service.ts:170

Update a cell value in a row. If the column is of type dropdown then the value is updated only if found in dropdown options.

Parameters ​

fmeaId ​

number

The ID of the FMEA to be updated

rowId ​

string

The ID of the row being updated

column ​

string

The column to update

value ​

string

The new value to be stored at the given row and column

Returns ​

Promise<boolean>

True if the cell is updated; otherwise false


updateColumn() ​

updateColumn(fmeaId, column, columnObject): Promise<Fmea>

Defined in: packages/web-backend/src/fmea/fmea.service.ts:236

Update a column's metadata.

Parameters ​

fmeaId ​

number

The FMEA ID

column ​

string

The column to update

columnObject ​

any

The column object containing name, type, and dropdown options

Returns ​

Promise<Fmea>

Updated FMEA object


updateColumnDetails() ​

updateColumnDetails(fmeaId, prev_name, column_body): Promise<Fmea>

Defined in: packages/web-backend/src/fmea/fmea.service.ts:368

Update column details (name, type, options).

Parameters ​

fmeaId ​

number

The FMEA id whose column should be updated

prev_name ​

string

Name of the column previously stored

column_body ​

any

Updated details of the column

Returns ​

Promise<Fmea>

Updated FMEA object


updateColumnName() ​

updateColumnName(fmeaId, column, newColumn): Promise<Fmea>

Defined in: packages/web-backend/src/fmea/fmea.service.ts:309

Update a column's name.

Parameters ​

fmeaId ​

number

The FMEA ID

column ​

string

The column to be updated

newColumn ​

string

The new column name

Returns ​

Promise<Fmea>

Updated FMEA object


updateColumnType() ​

updateColumnType(fmeaId, body): Promise<Fmea>

Defined in: packages/web-backend/src/fmea/fmea.service.ts:332

Update a column's type and related details.

Parameters ​

fmeaId ​

number

The FMEA ID

body ​

any

Old column name and new column, dropdown options, and type

Returns ​

Promise<Fmea>

Updated FMEA object


updateDropdownOptions() ​

updateDropdownOptions(fmeaId, column, dropdownOptions): Promise<Fmea>

Defined in: packages/web-backend/src/fmea/fmea.service.ts:203

Update dropdown options for a column. If the column type is string then options are not updated.

Parameters ​

fmeaId ​

number

FMEA ID

column ​

string

Column whose options should be updated

object[]

Updated array of dropdown options

Returns ​

Promise<Fmea>

The updated FMEA if changed; otherwise the original FMEA