MCPcopy
hub / github.com/mayneyao/eidos / reorderViews

Method reorderViews

packages/core/meta-table/view.ts:273–293  ·  view source on GitHub ↗

* Batch reorder views * @param viewIds Array of view ids in desired order (first = highest position)

(viewIds: string[])

Source from the content-addressed store, hash-verified

271 * @param viewIds Array of view ids in desired order (first = highest position)
272 */
273 public async reorderViews(viewIds: string[]): Promise<void> {
274 if (viewIds.length === 0) return
275
276 try {
277 await this.dataSpace.db.transaction(async (db) => {
278 let position = viewIds.length * 1000
279
280 for (const id of viewIds) {
281 this.dataSpace.syncExec2(
282 `UPDATE ${this.name} SET position = ? WHERE id = ?`,
283 [position, id],
284 db
285 )
286 position -= 1000
287 }
288 })
289 } catch (error) {
290 console.error("Failed to reorder views:", error)
291 throw new Error("Failed to reorder views")
292 }
293 }
294
295 private async checkAndReorderIfNeeded(tableId: string): Promise<void> {
296 const views = await this.list(

Callers 1

Calls 3

transactionMethod · 0.65
errorMethod · 0.65
syncExec2Method · 0.45

Tested by

no test coverage detected