Skip to content

feat: add update() for bulk attribute updates - #78

Merged
Artmann merged 1 commit into
mainfrom
feat/model-update-44
Jul 17, 2026
Merged

feat: add update() for bulk attribute updates#78
Artmann merged 1 commit into
mainfrom
feat/model-update-44

Conversation

@Artmann

@Artmann Artmann commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Summary

Adds an update(attributes) instance method to BaseModel so multiple attributes can be updated in one call instead of assigning fields one by one and calling save():

const product = await Product.find(id)

await product.update({ name: 'Chair 1', price: 42.0 })
  • Implemented as Object.assign(this, attributes) + save(), so all timestamp stamping and upsert behavior stays in one place — behaviorally identical to manual assign-then-save.
  • Typed as Partial<this>, matching the existing create(attributes: Partial<T>) convention; unknown keys and wrong value types are compile errors.
  • No fill() method: without a mass-assignment guard concept it would just be Object.assign, which users can already write.

Changes

  • packages/esix/src/base-model.ts — new update() method after save(), with JSDoc.
  • packages/esix/src/base-model.spec.ts — unit tests: existing-model update (merged $set, stamped updatedAt, upsert) and no-id insert (createdAt, wasRecentlyCreated).
  • packages/esix/src/integration-test.spec.ts — end-to-end test against the mock adapter.
  • packages/website/docs/inserting-and-updating-models.md — "Updating multiple attributes" docs section.

Testing

  • yarn lint, yarn typecheck, yarn test all green (238 tests, +3 new).
  • Reviewed by a fresh-context review pass before opening this PR.

Closes #44

🤖 Generated with Claude Code

@cursor

cursor Bot commented Jul 17, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@Artmann
Artmann merged commit f90df2e into main Jul 17, 2026
13 checks passed
@Artmann
Artmann deleted the feat/model-update-44 branch July 17, 2026 08:11
Artmann pushed a commit that referenced this pull request Jul 17, 2026
🤖 I have created a release *beep* *boop*
---


## [5.6.0](v5.5.1...v5.6.0)
(2026-07-17)


### Features

* add update() for bulk attribute updates
([#78](#78))
([f90df2e](f90df2e)),
closes [#44](#44)

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update models with multiple values at the same time

1 participant