Zaista / cypress-mongodb

Cypress MongoDB plugin
MIT License
17 stars 8 forks source link

Inserting a date as an object vs a string #14

Closed HemalR closed 2 years ago

HemalR commented 2 years ago

Hi,

First up, thanks for the super useful package, it has helped a lot!

Kind of a silly question (please let me know if this is not the right place to ask).


For a document to be added:

const document = {
  text: 'whatever'
  createdAt: new Date()
}

From my normal application (a Meteor application), inserting this results in a createdAt field that is of a Date type. However, doing the same within cypress:

cy.insertOne({
  text: 'whatever'
  createdAt: new Date()
});

... leads to a document where the createdAt field is of type string.

Is there something straightforward that I am missing? I have tried looking around but all documentation and queries regarding this seem to indicate that mongo should be automatically defaulting to an object type.

Thanks in advance!

Zaista commented 2 years ago

Hi, sorry for the late answer and thanks for raising this issue :) There's no proper support for complex object types, except objectId for now, but I will try and figure something out this weekend and publish it.

Zaista commented 2 years ago

Hello, just released v4.0.0 which should properly support complex object types (dates, objectIds, etc), please give it a go and let me know if there are further problems.

HemalR commented 2 years ago

You legend! Thank you so much (apologies for the delayed response I've been away).