Ottoman v2 .find date format

Hi,

Using the current model below, There is a discrepancy in the result for the dob field between .save() and .find() method.

const perry = new User({
  id: "a1",
  firstName: "Perry",
  lastName: "Mason",
  dob: new Date(),
});
const result = await perry.save();
console.log(result);

// Saved result
_Model {
  id: 'a1',
  firstName: 'Perry',
  lastName: 'Mason',
  dob: 2020-09-21T07:20:39.867Z,
  _type: 'User',
  _scope: '_default'
}

const result = await findById('a1');
console.log(result);

// Find result
_Model {
  id: 'a1',
  firstName: 'Perry',
  lastName: 'Mason',
  dob: '2020-09-21T07:29:43.111Z',
  _type: 'User',
  _scope: '_default'
}

May i know if it is possible to change the result of the dob for the .find() to return a Date object instead of a date String.

@Clive sorry for the delay, let me get back to you on this

@Clive

documents when stored in the database are serialized as string and when retrieved you get them back as string. All you need to do is cast it to your schema type

in the import include castSchema
and in the results when you get your data cast it to your schema like this

var myresult = castSchema(result,schema)

when you print myresult you should see dob as a date not string.