fix(database): cannot read properties of null (reading 'constructor')
This commit is contained in:
parent
1764b53a9b
commit
7cfa939f63
@ -15,7 +15,7 @@ export async function get(ctx: Context, next) {
|
|||||||
context: ctx,
|
context: ctx,
|
||||||
});
|
});
|
||||||
|
|
||||||
ctx.body = instance;
|
ctx.body = instance || {};
|
||||||
|
|
||||||
await next();
|
await next();
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import lodash, { omit } from 'lodash';
|
import lodash from 'lodash';
|
||||||
import { SingleAssociationAccessors, Transactionable } from 'sequelize';
|
import { SingleAssociationAccessors, Transactionable } from 'sequelize';
|
||||||
import { Model } from '../model';
|
import { Model } from '../model';
|
||||||
import { Appends, Except, Fields, Filter, TargetKey, UpdateOptions } from '../repository';
|
import { Appends, Except, Fields, Filter, TargetKey, UpdateOptions } from '../repository';
|
||||||
import { updateModelByValues } from '../update-associations';
|
import { updateModelByValues } from '../update-associations';
|
||||||
import { RelationRepository, transaction } from './relation-repository';
|
|
||||||
import { handleAppendsQuery } from '../utils';
|
import { handleAppendsQuery } from '../utils';
|
||||||
|
import { RelationRepository, transaction } from './relation-repository';
|
||||||
|
|
||||||
export interface SingleRelationFindOption extends Transactionable {
|
export interface SingleRelationFindOption extends Transactionable {
|
||||||
fields?: Fields;
|
fields?: Fields;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import crypto from 'crypto';
|
import crypto from 'crypto';
|
||||||
import { Model } from './model';
|
|
||||||
import { IdentifierError } from './errors/identifier-error';
|
import { IdentifierError } from './errors/identifier-error';
|
||||||
|
import { Model } from './model';
|
||||||
|
|
||||||
type HandleAppendsQueryOptions = {
|
type HandleAppendsQueryOptions = {
|
||||||
templateModel: any;
|
templateModel: any;
|
||||||
@ -10,6 +10,10 @@ type HandleAppendsQueryOptions = {
|
|||||||
export async function handleAppendsQuery(options: HandleAppendsQueryOptions) {
|
export async function handleAppendsQuery(options: HandleAppendsQueryOptions) {
|
||||||
const { templateModel, queryPromises } = options;
|
const { templateModel, queryPromises } = options;
|
||||||
|
|
||||||
|
if (!templateModel) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
const primaryKey = templateModel.constructor.primaryKeyAttribute;
|
const primaryKey = templateModel.constructor.primaryKeyAttribute;
|
||||||
|
|
||||||
const results = await Promise.all(queryPromises);
|
const results = await Promise.all(queryPromises);
|
||||||
|
Loading…
Reference in New Issue
Block a user