You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to use influx with my typescript/express app, but I cannot assign any strings in fields. here is my example:
import*asinfluxfrom'influx';import{Request,Response,NextFunction}from'express';import*asosfrom'os';constInflux=newinflux.InfluxDB({host: 'host',database: 'my_database',schema: [{measurement: 'express_response_times',fields: {path: influx.FieldType.STRING,duration: influx.FieldType.INTEGER},tags: ['host']}]});exportconstExpressTimer=function(req: Request,res: Response,next: NextFunction){conststart=Date.now();res.on('finish',()=>{constduration=Date.now()-start;Influx.writePoints([{measurement: 'express_response_times',tags: {host: os.hostname()},fields: { duration,path: req.path},//path gets the red underline with the error Type 'string' is not assignable to type 'FieldType'.timestamp: Date.now()}]);});returnnext();};
If I change path to be a number everything works fine, but because fields has type { [name: string]: influx.FieldType } and FieldType is an enum only numbers are assignable in fields when using typescript.
This is an issue when using influx@next, in the current stable version 5.0.7 FieldMap is used instead and is a type, but this issue should be addressed in the @next version.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I am trying to use influx with my typescript/express app, but I cannot assign any strings in fields. here is my example:
If I change path to be a number everything works fine, but because fields has type
{ [name: string]: influx.FieldType }
and FieldType is an enum only numbers are assignable in fields when using typescript.This is an issue when using influx@next, in the current stable version 5.0.7 FieldMap is used instead and is a type, but this issue should be addressed in the @next version.
The text was updated successfully, but these errors were encountered: