Reputation: 78439
I can't figure out how to enter a string with a line break in the Firestore web UI. The JavaScript SDK works fine and preserves reading/writing of newlines, but I need to edit some data manually during development, and nothing I'm trying in the UI is working.
I've tried copying and pasting firstline\nsecondline
, firstline\\nsecondline
, and copying the string from a document with two actual newline characters
firstline
second line
I've also tried copying and pasting a unicode linefeed in the center of the string.
Is there a way to enter a string with a newline in the Console UI that I'm missing, or no?
edit: There's a related question here, but it doesn't address how to enter a string with newlines using the console, which is what I'm trying to do.
Upvotes: 7
Views: 1389
Reputation: 131
As other users have stated, the console does not currently support this.
If you are willing to use a command line script, this will do the job:
https://gist.github.com/jakes-space/a01bc373a30e72c3736b77e5c2c23a84
It reads the doc at the given reference, opens its JSON in an editor, and writes the new version. Newline characters should be written as \n
, not \\n
.
(Disclaimers: I am the author. Please carefully check your changes before writing them.)
Upvotes: 2
Reputation: 317392
The console was not built for this use case. This applies to both Firestore and Realtime Database that came before it.
The console is primarily a debugging tool meant to give quick and easy access during development. It's not meant to be a primary interface for regular or administrative use. I suspect that the creators of the console intended for developers to build their own interfaces (admin web site, or CLI scripts) to meet specific needs like this. You are free to contact Firebase support to file a feature request if this is very important to you, but in this case I wouldn't get my hopes up.
Upvotes: 4