MCPcopy Create free account
hub / github.com/loopbackio/loopback-next / hasOne

Method hasOne

packages/repository/src/model.ts:213–224  ·  view source on GitHub ↗

* Define a new hasOne relation. * @param name - The name of the hasOne relation. * @param definition - The definition of the hasOne relation.

(
    name: string,
    definition: Omit<HasOneDefinition, 'name' | 'type' | 'targetsMany'>,
  )

Source from the content-addressed store, hash-verified

211 * @param definition - The definition of the hasOne relation.
212 */
213 hasOne(
214 name: string,
215 definition: Omit<HasOneDefinition, 'name' | 'type' | 'targetsMany'>,
216 ): this {
217 const meta: HasOneDefinition = {
218 ...definition,
219 name,
220 type: RelationType.hasOne,
221 targetsMany: false,
222 };
223 return this.addRelation(meta);
224 }
225
226 /**
227 * Define a new hasMany relation.

Callers 2

model.unit.tsFile · 0.80
getSequelizeModelMethod · 0.80

Calls 1

addRelationMethod · 0.95

Tested by

no test coverage detected