Frontmatter
| id | 8078 |
| title | Enhance Store DX: Add ''init'' parameter to add() and insert() for immediate record creation |
| state | Closed |
| labels | enhancementdeveloper-experienceai |
| assignees | tobiu |
| createdAt | Dec 10, 2025, 11:59 AM |
| updatedAt | Dec 10, 2025, 12:07 PM |
| githubUrl | https://github.com/neomjs/neo/issues/8078 |
| author | tobiu |
| commentsCount | 0 |
| parentIssue | null |
| subIssues | [] |
| subIssuesCompleted | 0 |
| subIssuesTotal | 0 |
| blockedBy | [] |
| blocking | [] |
| closedAt | Dec 10, 2025, 12:07 PM |
Improve DX by allowing
Neo.data.Storeto return fully instantiated records directly fromadd()andinsert().Proposal: Overload
add()andinsert()inNeo.data.Storewith an optional second parameterinit=false.add(items, init=false)initistrue, the method should return an Array of Record instances instead of the raw data objects.add(items)+initRecord(item)for each added item.insert(index, items, init=false)insertto optionally initialize and return the created records.Reasoning: Currently,
lazy recordsrequires a two-step process to get a usable Record instance:store.add(data); const record = store.get(id); // Required to get the RecordThis change simplifies it to:
const [record] = store.add(data, true);Architectural Note: This overloads the
collection.Basesignature. While slightly impure, the DX benefit for Store usage is significant.