# entity This document is auto-generated from the JSDoc comments in `src/store` by running `npm run api-doc`. ## `entity.create` *Source: `src/store/entity/create.js`* Creates a new entity (customer) in a customer group, recording history. ```js const fn = create(pool); const entity = await fn(42, 1, { customergroupId: 5, name: 'Doe', firstName: 'John' }); // => { id, customergroupId, firstName, name, createdAt, updatedAt } ``` ## `entity.delete` *Source: `src/store/entity/delete.js`* Deletes an entity by its id within a company. ```js const fn = del(pool); await fn(42, 1, 5); ``` ## `entity.getById` *Source: `src/store/entity/getById.js`* Returns a single entity by its id within a company. ```js const fn = getById(pool); const entity = await fn(42, 1, 5); // => { id, customergroupId, firstName, name, createdAt, updatedAt } ``` ## `entity.list` *Source: `src/store/entity/list.js`* Lists the entities (customers) of a company, optionally filtered by customer group or restricted to the 'customer' role. ```js const fn = list(pool); const entities = await fn(42, 1, { customergroupId: 5 }); // => [{ id, customergroupId, firstName, name, createdAt, updatedAt }] ``` ## `entity.update` *Source: `src/store/entity/update.js`* Updates the name and/or first name of an entity, recording history. ```js const fn = update(pool); const entity = await fn(42, 1, 5, { name: 'Doe', firstName: 'Jane' }); // => { id, customergroupId, firstName, name, createdAt, updatedAt } ```