Open suoc opened 5 years ago
There was no way to pass additional config to the collections automatically created by Neko, I'm putting some in now. The API will be
ko.Model('Timestamped', {
schema: ko.String,
etc: ko.String,
}, {
// new third parameter is collection config
// here you can pass all the options available in the nedb API, for instance
timestampData: true
})
Ok as of nekodb version 2.4.0 you should be able to pass in timestampData option to NeDB. Let me know how it goes
const DicomInfo = ko.Model('DicomInfo', {
PatientID: ko.String.default(''),
PatientName: ko.Document({ Alphabetic: ko.String.default('') }),
PatientSex: ko.String.default(''),
PatientAge: ko.String.default(''),
Modality: ko.String.default(''),
BodyPartExamined: ko.String.default(''),
AccessionNumber: ko.String.default(''),
TransferSyntaxUID: ko.String.default(''),
StudyInstanceUID: ko.String.default(''),
SeriesInstanceUID: ko.String.default(''),
SeriesNumber: ko.Option([ko.String,ko.Number]),
SeriesDescription: ko.String.default(''),
SOPInstanceUID: ko.String.default(''),
InstanceNumber: ko.Option([ko.String,ko.Number]),
StudyDate: ko.String.default(''),
StudyTime: ko.String.default(''),
StudyDatetime: ko.String.default(''),
filePath: ko.String.default('')
}, {
// new third parameter is collection config
// here you can pass all the options available in the nedb API, for instance
timestampData: true
});
[2019-10-08 09:25:26.510] [DEBUG] [dimse\index.js:95] [default] - saved doc: Instance { _id: [Getter/Setter], PatientID: [Getter/Setter], PatientName: [Getter/Setter], PatientSex: [Getter/Setter], PatientAge: [Getter/Setter], Modality: [Getter/Setter], BodyPartExamined: [Getter/Setter], AccessionNumber: [Getter/Setter], TransferSyntaxUID: [Getter/Setter], StudyInstanceUID: [Getter/Setter], SeriesInstanceUID: [Getter/Setter], SeriesNumber: [Getter/Setter], SeriesDescription: [Getter/Setter], SOPInstanceUID: [Getter/Setter], StudyDatetime: [Getter/Setter], filePath: [Getter/Setter] }
Not effective... There is not timesstamp properties.
Is there a way to got a saved object instead of model.
Ok I doubted myself, but they are in fact being saved to the database they're just not accessible via the model. All you have to do is add
createdAt: ko.Date.optional(),
updatedAt: ko.Date.optional(),
to the model and you will have the timestamps.
You can do model.slice()
to convert the object to a plain object, but it's still only going to have the fields the model knows about.
Thank you! That's ok for me.
Nedb's timestampData option can auto set updateAt and createdAt.
How nekodb to set this.