I am getting a json response and storing it in mongodb, however the fields that I don\'t need are also getting in to the database, is there anyway to strip the uneseccary fi
If you want to do this in a strongly-typed way, you can define a dummy/ideal object which satisfies your interface (const dummy: IMyInterface = {someField: "someVal"};
), and then filter incoming objects' fields against Object.keys(dummy)
. This way your compiler will complain if you update the interface without updating this 'filtering' code.