---
lang: en
title: 'API docs: repository'
keywords: LoopBack 4.0, LoopBack 4
sidebar: lb4_sidebar
permalink: /doc/en/lb4/apidocs.repository.html
---

<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@loopback/repository](./repository.md)

## repository package

[@loopback/repository](https://github.com/strongloop/loopback-next/tree/master/packages/repository)

## Classes

|  Class | Description |
|  --- | --- |
|  [AnyType](./repository.anytype.md) | Any type |
|  [ArrayType](./repository.arraytype.md) | Array type, such as string\[\] |
|  [BooleanType](./repository.booleantype.md) | Boolean type |
|  [BufferType](./repository.buffertype.md) | Buffer (binary) type |
|  [CrudRepositoryImpl](./repository.crudrepositoryimpl.md) | Repository implementation |
|  [DateType](./repository.datetype.md) | Date type |
|  [DefaultBelongsToRepository](./repository.defaultbelongstorepository.md) |  |
|  [DefaultCrudRepository](./repository.defaultcrudrepository.md) | Default implementation of CRUD repository using legacy juggler model and data source |
|  [DefaultHasManyRepository](./repository.defaulthasmanyrepository.md) |  |
|  [DefaultHasOneRepository](./repository.defaulthasonerepository.md) |  |
|  [DefaultKeyValueRepository](./repository.defaultkeyvaluerepository.md) | An implementation of KeyValueRepository based on loopback-datasource-juggler |
|  [DefaultTransactionalRepository](./repository.defaulttransactionalrepository.md) | Default implementation of CRUD repository using legacy juggler model and data source with beginTransaction() method for connectors which support Transactions |
|  [Entity](./repository.entity.md) | Base class for entities which have unique ids |
|  [EntityNotFoundError](./repository.entitynotfounderror.md) |  |
|  [Event](./repository.event.md) | Domain events |
|  [FilterBuilder](./repository.filterbuilder.md) | A builder for Filter. It provides fleunt APIs to add clauses such as <code>fields</code>, <code>order</code>, <code>where</code>, <code>limit</code>, <code>offset</code>, and <code>include</code>. |
|  [InvalidRelationError](./repository.invalidrelationerror.md) |  |
|  [Model](./repository.model.md) | Base class for models |
|  [ModelDefinition](./repository.modeldefinition.md) | Definition for a model |
|  [ModelMetadataHelper](./repository.modelmetadatahelper.md) |  |
|  [ModelType](./repository.modeltype.md) | Model type |
|  [NumberType](./repository.numbertype.md) | Number type |
|  [ObjectType](./repository.objecttype.md) | Object type |
|  [RepositoryMetadata](./repository.repositorymetadata.md) | Metadata for a repository |
|  [RepositoryMixinDoc](./repository.repositorymixindoc.md) | A dummy class created to generate the tsdoc for the members in repository mixin. Please don't use it.<!-- -->The members are implemented in function <a href="#RepositoryMixin">RepositoryMixin</a> |
|  [StringType](./repository.stringtype.md) | String type |
|  [UnionType](./repository.uniontype.md) | Union type, such as string \| number |
|  [ValueObject](./repository.valueobject.md) | Base class for value objects - An object that contains attributes but has no conceptual identity. They should be treated as immutable. |
|  [WhereBuilder](./repository.wherebuilder.md) | A builder for Where object. It provides fluent APIs to add clauses such as <code>and</code>, <code>or</code>, and other operators. |

## Enumerations

|  Enumeration | Description |
|  --- | --- |
|  [IsolationLevel](./repository.isolationlevel.md) | Isolation level |
|  [RelationType](./repository.relationtype.md) |  |

## Functions

|  Function | Description |
|  --- | --- |
|  [belongsTo(targetResolver, definition, propertyDefinition)](./repository.belongsto.md) | Decorator for belongsTo |
|  [bindModel(modelClass, ds)](./repository.bindmodel.md) | This is a bridge to the legacy DAO class. The function mixes DAO methods into a model class and attach it to a given data source |
|  [buildModelDefinition(target, def)](./repository.buildmodeldefinition.md) | Build model definition from decorations |
|  [constrainDataObject(originalData, constraint)](./repository.constraindataobject.md) | A utility function which takes a model instance data and enforces constraint(s) on it |
|  [constrainDataObjects(originalData, constraint)](./repository.constraindataobjects.md) | A utility function which takes an array of model instance data and enforces constraint(s) on it |
|  [constrainFilter(originalFilter, constraint)](./repository.constrainfilter.md) | A utility function which takes a filter and enforces constraint(s) on it |
|  [constrainWhere(originalWhere, constraint)](./repository.constrainwhere.md) | A utility function which takes a where filter and enforces constraint(s) on it |
|  [createBelongsToAccessor(belongsToMetadata, targetRepoGetter, sourceRepository)](./repository.createbelongstoaccessor.md) | Enforces a BelongsTo constraint on a repository |
|  [createHasManyRepositoryFactory(relationMetadata, targetRepositoryGetter)](./repository.createhasmanyrepositoryfactory.md) | Enforces a constraint on a repository based on a relationship contract between models. For example, if a Customer model is related to an Order model via a HasMany relation, then, the relational repository returned by the factory function would be constrained by a Customer model instance's id(s). |
|  [createHasOneRepositoryFactory(relationMetadata, targetRepositoryGetter)](./repository.createhasonerepositoryfactory.md) | Enforces a constraint on a repository based on a relationship contract between models. For example, if a Customer model is related to an Address model via a HasOne relation, then, the relational repository returned by the factory function would be constrained by a Customer model instance's id(s). |
|  [embedsMany(definition)](./repository.embedsmany.md) | Decorator for embedsMany |
|  [embedsOne(definition)](./repository.embedsone.md) | Decorator for embedsOne |
|  [ensurePromise(p)](./repository.ensurepromise.md) | Ensure the value is a promise |
|  [filterTemplate(strings, keys)](./repository.filtertemplate.md) |  |
|  [findByForeignKeys(targetRepository, fkName, fkValues, scope, options)](./repository.findbyforeignkeys.md) | Finds model instances that contain any of the provided foreign key values. |
|  [getModelRelations(modelCtor)](./repository.getmodelrelations.md) | Get metadata of all relations defined on a given model class. |
|  [hasMany(targetResolver, definition)](./repository.hasmany.md) | Decorator for hasMany Calls property.array decorator underneath the hood and infers foreign key name from target model name unless explicitly specified |
|  [hasOne(targetResolver, definition)](./repository.hasone.md) |  |
|  [includeRelatedModels(targetRepository, entities, include, options)](./repository.includerelatedmodels.md) | Returns model instances that include related models that have a registered resolver. |
|  [isBuiltinType(fn)](./repository.isbuiltintype.md) | Check if the provided function is a built-in type provided by JavaScript and/or Node.js. E.g. <code>Number</code>, <code>Array</code>, <code>Buffer</code>, etc. |
|  [isEntityNotFoundError(e)](./repository.isentitynotfounderror.md) |  |
|  [isFilter(candidate)](./repository.isfilter.md) | TypeGuard for Filter |
|  [isInvalidRelationError(e)](./repository.isinvalidrelationerror.md) |  |
|  [isTypeResolver(fn)](./repository.istyperesolver.md) | A function that checks whether a function is a TypeResolver or not. |
|  [model(definition)](./repository.model.md) | Decorator for model definitions |
|  [property(definition)](./repository.property.md) | Decorator for model properties |
|  [referencesMany(definition)](./repository.referencesmany.md) | Decorator for referencesMany |
|  [referencesOne(definition)](./repository.referencesone.md) | Decorator for referencesOne |
|  [relation(definition)](./repository.relation.md) | Decorator for relations |
|  [repository(repositoryName)](./repository.repository.md) | Decorator for repository injections on properties or method arguments |
|  [repository(model, dataSource)](./repository.repository_1.md) | Decorator for DefaultCrudRepository generation and injection on properties or method arguments based on the given model and dataSource (or their names) |
|  [RepositoryMixin(superClass)](./repository.repositorymixin.md) | A mixin class for Application that creates a .repository() function to register a repository automatically. Also overrides component function to allow it to register repositories automatically. |
|  [resolveType(fn)](./repository.resolvetype.md) | Resolve a type value that may have been provided via TypeResolver. |
|  [resolveType(fn)](./repository.resolvetype_1.md) |  |

## Interfaces

|  Interface | Description |
|  --- | --- |
|  [AndClause](./repository.andclause.md) | And clause |
|  [AnyObject](./repository.anyobject.md) | Objects with open properties |
|  [ApplicationWithRepositories](./repository.applicationwithrepositories.md) | Interface for an Application mixed in with RepositoryMixin |
|  [BelongsToDefinition](./repository.belongstodefinition.md) |  |
|  [BelongsToRepository](./repository.belongstorepository.md) | CRUD operations for a target repository of a BelongsTo relation |
|  [Class](./repository.class.md) | Interface for classes with <code>new</code> operator and static properties/methods |
|  [Connector](./repository.connector.md) | Common properties/operations for connectors |
|  [ConstructorFunction](./repository.constructorfunction.md) | Interface for constructor functions without <code>new</code> operator. |
|  [Count](./repository.count.md) | Count of Model instances that were successful for methods like <code>updateAll</code>, <code>deleteAll</code>, etc. |
|  [CrudConnector](./repository.crudconnector.md) | CRUD operations for connector implementations |
|  [CrudRepository](./repository.crudrepository.md) | Basic CRUD operations for ValueObject and Entity. No ID is required. |
|  [DataSource](./repository.datasource.md) | DataSource denotes a configured connector |
|  [EntityCrudRepository](./repository.entitycrudrepository.md) | CRUD operations for a repository of entities |
|  [EntityRepository](./repository.entityrepository.md) | Base interface for a repository of entities |
|  [ExecutableRepository](./repository.executablerepository.md) |  |
|  [Filter](./repository.filter.md) | Query filter object |
|  [HasManyDefinition](./repository.hasmanydefinition.md) |  |
|  [HasManyRepository](./repository.hasmanyrepository.md) | CRUD operations for a target repository of a HasMany relation |
|  [HasOneDefinition](./repository.hasonedefinition.md) |  |
|  [HasOneRepository](./repository.hasonerepository.md) | CRUD operations for a target repository of a HasMany relation |
|  [Inclusion](./repository.inclusion.md) | Inclusion of related items<!-- -->Note: scope means filter on related items<!-- -->Example: <code>{relation: 'aRelationName', scope: {&lt;AFilterObject&gt;}}</code> |
|  [KeyValueRepository](./repository.keyvaluerepository.md) | Key/Value operations for connector implementations |
|  [KVConnector](./repository.kvconnector.md) | Key/Value operations for connector implementations |
|  [ModelDefinitionSyntax](./repository.modeldefinitionsyntax.md) | DSL for building a model definition. |
|  [OrClause](./repository.orclause.md) | Or clause |
|  [Persistable](./repository.persistable.md) |  |
|  [PropertyDefinition](./repository.propertydefinition.md) | Property definition for a model |
|  [PropertyForm](./repository.propertyform.md) | See https://github.com/strongloop/loopback-datasource-juggler/issues/432 |
|  [RelationDefinitionBase](./repository.relationdefinitionbase.md) |  |
|  [Repository](./repository.repository.md) |  |
|  [SchemaMigrationOptions](./repository.schemamigrationoptions.md) |  |
|  [Transaction](./repository.transaction.md) | Local transaction |
|  [TransactionalRepository](./repository.transactionalrepository.md) | Repository Interface for Repositories that support Transactions |
|  [Type](./repository.type.md) |  |

## Namespaces

|  Namespace | Description |
|  --- | --- |
|  [juggler](./repository.juggler.md) |  |
|  [property](./repository.property.md) |  |
|  [repository](./repository.repository.md) |  |

## Variables

|  Variable | Description |
|  --- | --- |
|  [ANY](./repository.any.md) |  |
|  [BOOLEAN](./repository.boolean.md) |  |
|  [BUFFER](./repository.buffer.md) |  |
|  [CountSchema](./repository.countschema.md) | JSON Schema describing the Count interface. It's the response type for REST calls to APIs which return Count |
|  [DATE](./repository.date.md) |  |
|  [MODEL\_KEY](./repository.model_key.md) |  |
|  [MODEL\_PROPERTIES\_KEY](./repository.model_properties_key.md) |  |
|  [MODEL\_WITH\_PROPERTIES\_KEY](./repository.model_with_properties_key.md) |  |
|  [NUMBER](./repository.number.md) |  |
|  [RELATIONS\_KEY](./repository.relations_key.md) |  |
|  [STRING](./repository.string.md) |  |

## Type Aliases

|  Type Alias | Description |
|  --- | --- |
|  [BelongsToAccessor](./repository.belongstoaccessor.md) |  |
|  [Callback](./repository.callback.md) | Type alias for Node.js callback functions |
|  [Command](./repository.command.md) | Type for a command |
|  [Condition](./repository.condition.md) | Condition clause |
|  [Constructor](./repository.constructor.md) | Constructor type - class or function |
|  [DataObject](./repository.dataobject.md) | Type alias for strongly or weakly typed objects of T |
|  [DeepPartial](./repository.deeppartial.md) | An extension of the built-in Partial<T> type which allows partial values in deeply nested properties too. |
|  [Direction](./repository.direction.md) | Order by direction |
|  [EntityData](./repository.entitydata.md) |  |
|  [EntityResolver](./repository.entityresolver.md) |  |
|  [Fields](./repository.fields.md) | Selection of fields<!-- -->Example: <code>{afieldname: true}</code> |
|  [HasManyRepositoryFactory](./repository.hasmanyrepositoryfactory.md) |  |
|  [HasOneRepositoryFactory](./repository.hasonerepositoryfactory.md) |  |
|  [InclusionResolver](./repository.inclusionresolver.md) |  |
|  [KeyOf](./repository.keyof.md) | Key types of a given model, excluding operators |
|  [KeyValueFilter](./repository.keyvaluefilter.md) | Filter for keys |
|  [NamedParameters](./repository.namedparameters.md) | Named parameters, such as <code>{x: 1, y: 'a'}</code> |
|  [Operators](./repository.operators.md) | Operators for where clauses |
|  [Options](./repository.options.md) | Type alias for Node.js options object |
|  [Order](./repository.order.md) | Order by<!-- -->Example: <code>{afieldname: 'ASC'}</code> |
|  [PositionalParameters](./repository.positionalparameters.md) | Positional parameters, such as \[1, 'a'\] |
|  [PredicateComparison](./repository.predicatecomparison.md) | Matching predicate comparison |
|  [PropertyMap](./repository.propertymap.md) |  |
|  [PropertyType](./repository.propertytype.md) | This module defines the key classes representing building blocks for Domain Driven Design. See https://en.wikipedia.org/wiki/Domain-driven\_design\#Building\_blocks |
|  [RelationDefinitionMap](./repository.relationdefinitionmap.md) | A key-value map describing model relations. A relation name is used as the key, a relation definition is the value. |
|  [RelationMetadata](./repository.relationmetadata.md) | A union type describing all possible Relation metadata objects. |
|  [RepositoryDecorator](./repository.repositorydecorator.md) | Type definition for decorators returned by <code>@repository</code> decorator factory |
|  [ShortHandEqualType](./repository.shorthandequaltype.md) | Value types for <code>{propertyName: value}</code> |
|  [TransactionalEntityRepository](./repository.transactionalentityrepository.md) | A type for CRUD repositories that are backed by IDs and support Transactions |
|  [TypeResolver](./repository.typeresolver.md) | A type resolver is a function that returns a class representing the type, typically a Model or Entity (e.g. Product).<!-- -->We use type resolvers to break require() loops when defining relations. The target model (class) is provided via a provider, thus deferring the actual reference to the class itself until later, when both sides of the relation are created as JavaScript classes. |
|  [Where](./repository.where.md) | Where clause |


