@@ -95,7 +95,7 @@ export class KnexDriver implements Driver {
9595
9696 async findOne ( objectName : string , id : string | number , query ?: any , options ?: any ) {
9797 if ( id ) {
98- return await this . getBuilder ( objectName , options ) . where ( 'id ' , id ) . first ( ) ;
98+ return await this . getBuilder ( objectName , options ) . where ( '_id ' , id ) . first ( ) ;
9999 }
100100 if ( query ) {
101101 const results = await this . find ( objectName , { ...query , limit : 1 } , options ) ;
@@ -116,13 +116,13 @@ export class KnexDriver implements Driver {
116116
117117 async update ( objectName : string , id : string | number , data : any , options ?: any ) {
118118 const builder = this . getBuilder ( objectName , options ) ;
119- await builder . where ( 'id ' , id ) . update ( data ) ;
120- return { id, ...data } ; // Return patched data? Or fetch fresh?
119+ await builder . where ( '_id ' , id ) . update ( data ) ;
120+ return { _id : id , ...data } ; // Return patched data? Or fetch fresh?
121121 }
122122
123123 async delete ( objectName : string , id : string | number , options ?: any ) {
124124 const builder = this . getBuilder ( objectName , options ) ;
125- return await builder . where ( 'id ' , id ) . delete ( ) ;
125+ return await builder . where ( '_id ' , id ) . delete ( ) ;
126126 }
127127
128128 async count ( objectName : string , filters : any , options ?: any ) : Promise < number > {
@@ -179,7 +179,7 @@ export class KnexDriver implements Driver {
179179
180180 if ( ! exists ) {
181181 await this . knex . schema . createTable ( tableName , ( table ) => {
182- table . string ( 'id ' ) . primary ( ) ;
182+ table . string ( '_id ' ) . primary ( ) ;
183183 table . timestamp ( 'created_at' ) . defaultTo ( this . knex . fn . now ( ) ) ;
184184 table . timestamp ( 'updated_at' ) . defaultTo ( this . knex . fn . now ( ) ) ;
185185 if ( obj . fields ) {
0 commit comments