date field generator should have a format option
idc77 opened this issue · 3 comments
I'm not sure if this is already possible,
I'm trying to generate a date in the following format:
YYYY/MM/DD
Example
1970/01/01
I can't use int, I can't use decimal. Is there a way I could format the int?
Also I'm not sure what "nullpercentage" means
On 2nd thought, I really need to generate a date, not ints.
The date field type should have a "format" option, when present it would allow you to present a time.Date.Format string like
2006/01/02
There are just too many inconsistencies with this library. Pitty.
I think it's best to just use gofaker an do the inserts "by hand".
It was a good idea and it work for simple data structures ultimately not a fit for my use cases.
Feel free to close my issues if you don't want to solve em.
tc
Mongodb dates are stored ad int64 so there is no concept of format when inserting a date in the database
However you can request a specific format when you query the database like this:
db.collection.aggregate(
[
{
$project: {
formattedDate: { $dateToString: { format: "%d/%m/%Y", date: "$dateField" } }
}
}
]
)
If you want to have a field with a value like 2006/01/02
, you should store it as string. You can generate something like this with the stringFromParts
generator