Open lordrip opened 2 years ago
I've forgot to mention, if I can help somehow investigating this further, just let me know :)
As a workaround, I'm using ejs forcing an ISO string
entity: MyEntity
items:
sync{1..3}:
topic: 'a-given-topic'
id: '{{datatype.uuid}}'
company: '@company*'
syncDateTime: <%= (new Date()).toISOString() %>
Hi,
I have the same problem, I would love to see just ISO date returned by date.past
and date.future
, as faker-js returns exactly that, forcing us to use Date().toISOString defeats all purposes of using faker here...
(thanks @lordrip for the workaround)
Another way to approach this in the meantime could be leveraging Processors
.
import { IProcessor } from 'typeorm-fixtures-cli';
// Importing 'YourEntityEntity' it's optional, it's mostly for typing purposes
import { YourEntity } from './yourentity';
import { faker } from '@faker-js/faker';
export default class EntityProcessor implements IProcessor<YourEntity> {
async preProcess(name: string, entity: YourEntity): Promise<YourEntity> {
// Here we can leverage any fakerjs module
// We could also leverage location.zipCode but for the sake of the example, we send some parameters as well
const zipCode = faker.string.numeric({ length: 5, allowLeadingZeros: true });
return { ...entity, zipCode };
}
}
then in the fixture yaml
file
entity: YourEntity
processor: ./EntityProcessor # Load the above processor
items:
provider{1..10}:
id: '{{string.uuid}}'
# zipCode is no longer required here as we're providing it through the processor
name: '{{company.name}}'
address: '{{location.streetAddress}}'
phone: '{{phone.number}}'
email: '{{internet.email}}'
representativeName: '{{person.fullName}}'
representativePhone: '{{phone.number}}'
representativeEmail: '{{internet.email}}'
Your Environment
Hi there, first of all, thanks for providing this library to the community, very cool project πββοΈ .
I'm facing a situation in which when I use a column marked as
timestamptz
, any kind of date gets transformed into a long date stringColumn definition
then it fails because it cannot parse the following date format
Mon Nov 16 1992 23:28:29 GMT+0100 (Central European Standard Time)
Stacktrace excerpt
Curious enough, If I remove it, then it works
Have you face a similar situation in the past?