Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set a updateAt time ? #56

Open
suoc opened this issue Sep 26, 2019 · 7 comments
Open

How to set a updateAt time ? #56

suoc opened this issue Sep 26, 2019 · 7 comments

Comments

@suoc
Copy link

suoc commented Sep 26, 2019

Nedb's timestampData option can auto set updateAt and createdAt.

How nekodb to set this.

@4strid
Copy link
Owner

4strid commented Sep 26, 2019

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
})

@4strid
Copy link
Owner

4strid commented Oct 1, 2019

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

@suoc
Copy link
Author

suoc commented Oct 8, 2019

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.

@suoc
Copy link
Author

suoc commented Oct 11, 2019

Is there a way to got a saved object instead of model.

@4strid
Copy link
Owner

4strid commented Oct 11, 2019

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.

@4strid
Copy link
Owner

4strid commented Oct 11, 2019

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.

@suoc
Copy link
Author

suoc commented Oct 11, 2019

Thank you! That's ok for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants