File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ import { ProjectModel } from './Project.js';
7
7
import { BaseAuthedModel , MethodParams , roleCheck , idMatch } from './utils.js' ;
8
8
import { Context } from '../../handler.js' ;
9
9
import type * as gql from '../../../@types/graphql.js' ;
10
- import { ProjectSchema } from '../schemas/Project.js' ;
10
+ import Project , { ProjectSchema } from '../schemas/Project.js' ;
11
11
12
12
const ObjectId = mongoose . Types . ObjectId ;
13
13
@@ -188,6 +188,7 @@ export class CameraModel {
188
188
if ( defaultProjReg ) defaultProjReg . active = true ;
189
189
else {
190
190
cam . projRegistrations . push ( {
191
+ _id : new ObjectId ( ) ,
191
192
projectId : 'default_project' ,
192
193
active : true ,
193
194
} ) ;
@@ -197,7 +198,10 @@ export class CameraModel {
197
198
198
199
// make sure there's a Project.cameraConfig record for this camera
199
200
// in the default_project and create one if not
200
- let [ defaultProj ] = await ProjectModel . getProjects ( { _ids : [ 'default_project' ] } , context ) ;
201
+ let defaultProj = await Project . findOne ( { _id : 'default_project' } ) ;
202
+ if ( ! defaultProj ) {
203
+ throw new CameraRegistrationError ( 'Could not find default project' ) ;
204
+ }
201
205
202
206
let addedNewCamConfig = false ;
203
207
const camConfig = defaultProj . cameraConfigs . find ( ( cc ) => idMatch ( cc . _id , input . cameraId ) ) ;
Original file line number Diff line number Diff line change @@ -173,7 +173,8 @@ export class ProjectModel {
173
173
try {
174
174
return await retry (
175
175
async ( ) => {
176
- const [ project ] = await ProjectModel . getProjects ( { _ids : [ projectId ] } , context ) ;
176
+ let project = await Project . findOne ( { _id : projectId } ) ;
177
+ if ( ! project ) throw new NotFoundError ( 'Project not found' ) ;
177
178
console . log ( 'originalProject: ' , project ) ;
178
179
179
180
const newCamConfig = {
You can’t perform that action at this time.
0 commit comments