brianc / node-postgres-docs

Documentation for node-postgres
https://node-postgres.com
MIT License
97 stars 94 forks source link

Cannot read property 'handleCommandComplete' of null or Cannot read property handleDataRow #135

Closed cjagdish closed 3 years ago

cjagdish commented 3 years ago

Record insert or edit i have some errors (Cannot read property 'handleCommandComplete' of null or Cannot read property handleDataRow).

PG Version ^8.6.0, Node Version 12.16.1, Typeorm Version ^0.2.32.

After changes i was solve my problem in node_modules =>pg=>lib=>client.js _handleDataRow(msg) { if (this.activeQuery !== null) { // new line added this.activeQuery.handleDataRow(msg)

}

_handleCommandComplete(msg) { if (this.activeQuery !== null) { //new line added this.activeQuery.handleCommandComplete(msg, this.connection) }

charmander commented 3 years ago

Please describe in detail what you did to encounter the bug, either in brianc/node-postgres#1872 or a new issue on brianc/node-postgres. (See brianc/node-postgres#1685 for why this patch isn’t applied.)

cjagdish commented 3 years ago

=> app.module.ts

@Module({ imports: [TypeOrmModule.forRoot({ type: 'postgres', host: process.env.HOST, port: parseInt(process.env.PORT), username: process.env.USER, synchronize: false, logger: "debug", logging: true, entities: ["dist/**/entity.js"] }),

=> entity.ts

@Entity('doc.organizations') export class OrganizationsEntity extends BaseEntity {

@PrimaryGeneratedColumn('uuid') orgId: string;
@Column('text') orgName: string;
@Column('text') description: string;
@Column('simple-json') address: object
@Column('text') email: string;
@Column('text') mobile: string;
@Column('timestamp', { generated: true }) createdAt: string;

}

=>app.service.ts

class AppService { constructor(@InjectRepository(OrganizationsEntity) private readonly orgService: Repository)

public async CreateOrganization(body) { try { const result = await this.orgService.insert(body); console.log("success",result);

} catch (e) {
 ocnsole.log("error",e);
}

} }