Project CRUD backed by SQLite.
All read queries filter WHERE deletedAt IS NULL by default.
Hard deletes are replaced with soft-deletes: deletedAt = datetime('now').
Use getDeletedAll / restore for recycle-bin operations.
Use getAllIncludeDeleted for data-management cleanup that must
span both live and soft-deleted projects.
Methods
(static) count(workspaceIdopt) → {number}
Count total non-deleted projects.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
workspaceId |
string |
<optional> |
— If provided, scope to this workspace (ACL-001). |
Returns:
- Type
- number
(static) create(project)
Create a project.
Parameters:
| Name | Type | Description |
|---|---|---|
project |
Object | — Must include |
(static) deleteById(id)
Soft-delete a project by ID.
The row is retained in the database and visible via getDeletedAll.
Cascade soft-deletes for tests and runs are handled by the caller.
Parameters:
| Name | Type | Description |
|---|---|---|
id |
string |
(static) getAll(workspaceIdopt) → {Array.<Object>}
Get all non-deleted projects.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
workspaceId |
string |
<optional> |
— If provided, scope to this workspace (ACL-001). |
Returns:
- Type
- Array.<Object>
(static) getAllIncludeDeleted(workspaceId) → {Array.<Object>}
Get all projects (live + soft-deleted) for a workspace. Used by data-management cleanup endpoints that must clear derived data across all projects regardless of soft-delete status.
Parameters:
| Name | Type | Description |
|---|---|---|
workspaceId |
string |
Returns:
- Type
- Array.<Object>
(static) getById(id) → {Object|undefined}
Get a non-deleted project by ID.
Parameters:
| Name | Type | Description |
|---|---|---|
id |
string |
Returns:
- Type
- Object | undefined
(static) getByIdInWorkspace(id, workspaceId) → {Object|undefined}
Get a non-deleted project by ID, scoped to a workspace (ACL-001). Returns undefined if the project doesn't exist OR belongs to a different workspace. Use this in route handlers to prevent cross-workspace IDOR.
Parameters:
| Name | Type | Description |
|---|---|---|
id |
string | |
workspaceId |
string |
Returns:
- Type
- Object | undefined
(static) getByIdIncludeDeleted(id) → {Object|undefined}
Get a project by ID (including soft-deleted — needed for restore and audit).
Most callers should use getById which excludes deleted items.
Parameters:
| Name | Type | Description |
|---|---|---|
id |
string |
Returns:
- Type
- Object | undefined
(static) getDeletedAll(workspaceIdopt) → {Array.<Object>}
Get all soft-deleted projects (recycle bin).
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
workspaceId |
string |
<optional> |
— If provided, scope to this workspace (ACL-001). |
Returns:
- Type
- Array.<Object>
(static) hardDeleteById(id)
Hard-delete a project by ID (permanent — use only for purge operations).
Parameters:
| Name | Type | Description |
|---|---|---|
id |
string |
(static) restore(id) → {boolean}
Restore a soft-deleted project (clear deletedAt).
Parameters:
| Name | Type | Description |
|---|---|---|
id |
string |
Returns:
Whether the project was found and restored.
- Type
- boolean
(static) update(id, fields)
Update specific fields on a project.
Parameters:
| Name | Type | Description |
|---|---|---|
id |
string | |
fields |
Object |