1

Is there way I can update all the date field format existing in documents of couch db

change format from

DateTime : "07-29-2017 19:07:23"

to

DateTime : "2017-07-29 19:07:23"

Jamesjin
  • 371
  • 2
  • 6
  • 15

2 Answers2

1

There's no automated way to do this, aside from writing a script that updates each of your documents.

An alternative, depending on your exact situation, might be to use a view to manipulate the data as it's being read. The view could detect the existing date format, and if it's the old one, convert it before displaying the document.

This would change the way you query the data, though--you'd have to request the new view, which could obviously be a deal-breaker in some scenarios.

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
0

First, you need a way to apply a function to every document. To do so, I suggest that you use pouchdb-migrate.

Finally, you only have to define your function and integrate it into pouchdb-migrate. You can either parse the date and convert it or simply do some string manipulation.

Alexis Côté
  • 3,670
  • 2
  • 14
  • 30