CenterForDigitalHumanities / CenterForDigitalHumanities/TPEN-services

`set` properties vs `update` documents

Open
#204 0 comments 0 reactions 0 assignees View on GitHub
core-functionality enhancement
Dominant language
JavaScript
Stars
2
Forks
0
PR merge metrics
No merged PRs in 30d

Description

This is in relation to the Driver and MongoDB Controller for interacting with the Private TPEN3 Mongo Data.

In the Classes we are noticing the need to "load objects" in order to update() them. This is because most updating in the Classes consider the act of updating to be document replacements. This means update actions need to know the entire document.

It is a regular occurrence that all we really need to do is update a property (sometimes more than one) on a document. It would be nice if we didn't first have to load() the object. In these cases we should be able to ask the class to set a property without having to load or transmit the entire document.

For Mongo's part, the MongoDB `update()` does what we need.

**db.collection.update(query, update, options)**

> Modifies an existing document or documents in a collection. The method can modify specific fields of an existing document or documents or replace an existing document entirely, depending on the update parameter.
>
> By default, the db.collection.update() method updates a single document. Include the option multi: true to update all documents that match the query criteria.

Contributor guide

Open the contributing guide

Research direction

Start with the Driver and MongoDB Controller entry points, then trace how the Classes currently use load() and update(). Compare the requested property updates with MongoDB's db.collection.update(query, update, options), including single-document and multi-document behavior. Done means callers can update selected properties without loading or transmitting the full document while document replacement remains supported.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, mongodb
Domain
backend, database
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.