Open adilansari opened 1 year ago
Please answer the following questions for yourself before submitting an issue. YOU MAY DELETE THE PREREQUISITES SECTION.
@TigrisCollection('shoes') class Shoe { @PrimaryKey({ order: 1 }) id!: string @Field() purchaseDate!: string @Field({ timestamp: 'createdAt' }) inserted?: Date }
For the above collection I expect purchaseDate to be string and inserted to be a Date type in the retrieved document.
purchaseDate
inserted
Both inserted and purchaseDate are of Date type.
Please help provide information about the failure if this is a bug. If it is not a bug, please remove the rest of this template.
describe('Date field tests', () => { let collection: Collection<Shoe> beforeEach(async () => { const db = getClient(ProjectCatalog).getDatabase() collection = await db.createOrUpdateCollection<Shoe>(Shoe) }) it('deserialize date', async () => { const docs: Array<Shoe> = [ { id: '1', purchaseDate: '2020-04-13T00:00:00.000+08:00', }, ] const inserted = await collection.insertMany(docs) expect(inserted).toHaveLength(docs.length) const readDoc = await collection.findOne() expect(readDoc).toBeDefined() expect(readDoc?.inserted).toBeInstanceOf(Date) // all good expect(readDoc?.purchaseDate).not.toBeInstanceOf(Date) // This test fails expect(readDoc?.purchaseDate).toBeInstanceOf(String) }) })
Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.
You can find Tigris SDK version on your local dev project by executing npm list | grep "tigrisdata/core"
npm list | grep "tigrisdata/core"
^1.0.0-beta.50
Please include any relevant log snippets or files here.
Prerequisites
Please answer the following questions for yourself before submitting an issue. YOU MAY DELETE THE PREREQUISITES SECTION.
Expected Behavior
For the above collection I expect
purchaseDate
to be string andinserted
to be a Date type in the retrieved document.Current Behavior
Both
inserted
andpurchaseDate
are of Date type.Failure Information (for bugs)
Please help provide information about the failure if this is a bug. If it is not a bug, please remove the rest of this template.
Steps to Reproduce
For the following collection
Context
Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.
^1.0.0-beta.50
Failure Logs
Please include any relevant log snippets or files here.