le-yams / nbmongo

A NetBeans plugin for browsing MongoDB
Other
26 stars 6 forks source link

Make query criteria editing more user friendly #58

Open le-yams opened 8 years ago

le-yams commented 8 years ago

I create this issue regarding to @witoldsz comment in #36

Hi, I am wondering if that would not be more comfortable to replace the Criteria, Projection, Sort trio (featuring edit/clear buttons and modal editor) with just one text area with plain JSON and history of that texfield similar to the one of (JDBC) Databases bundled with NetBeans.

An extra advantage is that there would be no extra "click steps" required to get into the query (1st is edit button, then if 2nd one to get to projection or sort, then 3rd click to accept and close the editor).

Maybe something like this:

{{query: {}, projection: {}, sort: {}}
le-yams commented 8 years ago

Hi Witold,

So there are two points here:

Regarding the first one, both approaches have pros and cons. Using the dialog keeps the displayed query information consistent with the displayed results. Allowing to directly edit the query implies to notify, one way or the other, the user that he modified the query (and so he needs to hit the refresh/run button). Also it is a bit more complex to implement (which is the main reason I choosed the dialog approach when I started writing the plugin). But I agree it would be more user friendly, I'll give it a try (but to be honest that's not a top priority).

Regarding the "3 fields" matter, I'm not very fond of the idea of imposing a specific json structure just to write the query in a single field. The idea is that a user only need to know mongodb related syntax/features and don't have to handle an extra syntax specific to this plugin. Note that you can switch between the filter/project/sort fields using CTRL+TAB shortcut.

witoldsz commented 8 years ago

Allowing to directly edit the query implies to notify, one way or the other, the user that he modified the query (and so he needs to hit the refresh/run button).

The NetBeans official plugin for JDBC databases does not notify when you edit the query. It's like this since... forever I guess. I saw other database tools with same approach, i.e. a query text area at the top with results below (including MongoDB apps like Robomongo) and a "RUN" button, and I have never seen anyone mislead by that. Everyone know they have to re-run the query to update the results.

Regarding the "3 fields" matter, I'm not very fond of the idea of imposing a specific json structure just to write the query in a single field.

You are right. Single area for query with criteria and sort seems odd, because it would not follow the MongoDB standard, as there is no specification describing the query/projection/sort trio as a single document. Unless, of course, it would be doable to let us enter commands like in official documentation:

db.inventory.find( { type: { $in: [ 'food', 'snacks' ] }, {type:''} } ).sort({date:-1})

, but I guess this plugin does not work that way (and I am not sure it's bad at all). Still, one single text area for everything seems pragmatic and comfortable (like in SQL), especially that the "reset" button would set the structure, so no one would actually have to remember how it goes. The benefits are a single "copy/paste" option to share query with someone or save somewhere for later use, easier management if the #36 comes true, no excessive "clicking" to get there, etc...

Thanks for your insight!

le-yams commented 8 years ago

The NetBeans official plugin for JDBC databases does not notify when you edit the query. It's like this since... forever I guess. I saw other database tools with same approach, i.e. a query text area at the top with results below (including MongoDB apps like Robomongo) and a "RUN" button, and I have never seen anyone mislead by that. Everyone know they have to re-run the query to update the results.

You're right, that's not a very big deal. However it would be a plus to have this notification (like a * char appearing somewhere for exemple).

but I guess this plugin does not work that way (and I am not sure it's bad at all)

Indeed, this plugin aims to be as simple and straightforward as possible. Complex stuff should be done using the mongo shell and scripts.

Some thought: I think that having the 3 fields put directly in the view (no dialog to edit), would make hard to organize them in a user friendly way. Users migth want them of a decent size and be able to resize them. That's doable with multiple splitpanes but I'm not convinced it would be very user friendly.

What could be a solution is to use your idea of a single editor field with a predifined filter/projection/sort json structure but in association with guarded blocks (so the user only writes the usual filter/projection/sort json documents he wants). I'm not very familiar with this netbeans feature api but I think I'll investigate on this.

Best regards, Yann

witoldsz commented 8 years ago

What could be a solution is to use your idea of a single editor field with a predifined filter/projection/sort json structure but in association with guarded blocks (so the user only writes the usual filter/projection/sort json documents he wants).

They also doesn't come without a price: the guarding block might be a problem when one would like to copy/paste the query as a whole.

Maybe it could be good enough if there was a validator which could throw some error at the user's face on submit, when they have broken the schema, like renamed (but not necessary removed) the "query/projection/sort" keys or added extra ones...

le-yams commented 8 years ago

Maybe it could be good enough if there was a validator which could throw some error at the user's face on submit, when they have broken the schema, like renamed (but not necessary removed) the "query/projection/sort" keys or added extra ones...

This implies that the user must know and type all that extra json in addition of the filter/projection/sort documents. I really don't want that, it's forcing the user to write boilerplate code he has no interest in. It's time consuming for him and if he makes a mistake on this, he will get a validation error on something he doesn't care (and should not handle).

They also doesn't come without a price: the guarding block might be a problem when one would like to copy/paste the query as a whole.

Actually the problem only concerns the paste action. There could be a button "load from clipboard" somewhere or something like that.

Best regards, Yann

witoldsz commented 8 years ago

:+1:

Chris2011 commented 7 years ago

I would prefer the same functionality as for SQL statements. It is more consistent to the existing one. You have a editor which supports JS plus mongo specific JS functions. The editor should resolve the mongo document name while typing to make it easier. And after hitting execute the result should be shown.