Posts

Showing posts with the label typeorm

Making fields/columns optional/required using TypeORM

Making fields/columns optional/required using TypeORM I have this cURL command that successfully wrote to MySQL: curl -d '{"key1":"value", "key2":"value"}' -H "Content-Type: application/json" -X POST http://localhost:3010/customers This query was able to write to the db through via the TypeORM library, like so: import {Customer} from "../entity/customer"; import {getRepository} from "typeorm"; const RCustomer = getRepository(Customer); router.post('/', (req, res, next) => { return RCustomer.save(req.body).then(v => res.json({success: v})); }); that never should have happened since "key1" and "key2" aren't fields in the customers table! the customers model looks like: 'use strict'; import {Entity, PrimaryGeneratedColumn, Column, Index} from "typeorm"; import {MooveBaseEntity} from "./base"; @Entity() @Index(["email"], { unique: true ...