You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Suppose the user wants to find a comment with a particular id (in a post with a particular id), and update the comment's text. I can proceed to type up a query to do it, but it's obviously extremely annoying (too annoying for me to type it up, in fact).
The same problem applies if we want to delete a particular comment, or do any kind of modification to the array. I don't quite know what an elegant way to solve this is. Leaving in subsequent for now.
@mlucy A function pseudo-type seems like a very good idea.
deleteWhere seems unnecessary, it is equivalent to filter . not.
updateWhere is a bad name but would be very useful. Perhaps it could be called mapOn. It would also be useful to have an indexed version too, related to #2574. I would call it imapOn.
I have also seen many users trying to update a specific index inside an array. Perhaps a shortcut syntax such as {2: 'foo'} could replace the third item in the array?
We can have a singleRowSelection turn into a singleFieldSelection when a field value is selected. You can use .delete or .replace on them. .update can work if they're an object.
Such an API will also make things straightforward, if/when we support performant updates on individual fields of a row that has other very large fields.
Activity
coffeemug commentedon Mar 20, 2014
@neumino suggested a couple of commands in https://github.com/rethinkdb/company/issues/17#issuecomment-37899006:
Add methods like
updateField,deleteWhere,updateWhere(we would have to find better names)Add an element in a field
Delete an element in an array
Update an element in an array
The point of
updateFieldis to easily update a nested field without having to do tons ofmap/do/merge(so the first argument can be{nested: {field: true}}This syntax is close to Mongo's one, and we would provide something better in some cases -- e.g: https://jira.mongodb.org/browse/SERVER-1243
Marking as proposal.
mlucy commentedon Mar 20, 2014
Rather than having
updateField, we could introduce a function pseudotype and let people write:This would also let people update multiple fields at once.
AtnNn commentedon Jun 20, 2014
@mlucy A function pseudo-type seems like a very good idea.
deleteWhereseems unnecessary, it is equivalent tofilter . not.updateWhereis a bad name but would be very useful. Perhaps it could be calledmapOn. It would also be useful to have an indexed version too, related to #2574. I would call itimapOn.I have also seen many users trying to update a specific index inside an array. Perhaps a shortcut syntax such as
{2: 'foo'}could replace the third item in the array?srh commentedon Jun 20, 2014
We can have a singleRowSelection turn into a singleFieldSelection when a field value is selected. You can use
.deleteor.replaceon them..updatecan work if they're an object.Such an API will also make things straightforward, if/when we support performant updates on individual fields of a row that has other very large fields.
coffeemug commentedon Jun 24, 2014
Moving to 1.14-polish. This isn't as important as major features, and I'd like to agree on those first. We can tackle this later.
coffeemug commentedon Aug 13, 2014
Closing in favor of #2692.