I'm trying to use the SnakeNamingConvention in my nest and TypeORM project but am getting a query error when I attempt to use the BaseEntity.#save method on my custom entity. Here are relevant pieces of code:
app.module.ts
import { SnakeNamingStrategy } from 'typeorm-naming-strategies'
@Module({
imports: [
ConfigModule.forRoot({ isGlobal: true }),
TypeOrmModule.forRoot({ namingStrategy: new SnakeNamingStrategy() }),
GraphQLModule.forRoot({ autoSchemaFile: 'schema.gql' }),
UserModule,
],
})
users.entity.ts
@ObjectType()
@Entity('user')
export class User extends BaseEntity {
@Field()
@PrimaryGeneratedColumn('uuid')
id: string
@Field()
@Column({ length: 20, nullable: false })
firstName: string
@Field()
@Column({ length: 25, nullable: false })
lastName: string
}
users.service.ts
@Injectable()
export class UserService {
create(createUserInput: CreateUserServiceInput) {
return User.create(createUserInput).save()
}
}
My error is:
column "firstName" of relation "user" does not exist