mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-13 13:17:45 +02:00
Accounts listWorkspaces (#483)
Signed-off-by: Ilya Sumbatyants <ilya.sumb@gmail.com>
This commit is contained in:
+11
-1
@@ -16,7 +16,7 @@
|
||||
|
||||
import { program } from 'commander'
|
||||
import { MongoClient, Db } from 'mongodb'
|
||||
import { getAccount, createAccount, assignWorkspace, createWorkspace, ACCOUNT_DB, dropWorkspace, dropAccount } from '@anticrm/account'
|
||||
import { getAccount, createAccount, assignWorkspace, createWorkspace, ACCOUNT_DB, dropWorkspace, dropAccount, listWorkspaces } from '@anticrm/account'
|
||||
import { createContributingClient } from '@anticrm/contrib'
|
||||
import core, { TxOperations } from '@anticrm/core'
|
||||
import { encode } from 'jwt-simple'
|
||||
@@ -164,6 +164,16 @@ program
|
||||
})
|
||||
})
|
||||
|
||||
program
|
||||
.command('list-workspaces')
|
||||
.description('List workspaces')
|
||||
.action(async () => {
|
||||
return await withDatabase(mongodbUri, async (db) => {
|
||||
const workspacesJSON = JSON.stringify(await listWorkspaces(db), null, 2)
|
||||
console.info(workspacesJSON)
|
||||
})
|
||||
})
|
||||
|
||||
program
|
||||
.command('drop-account <name>')
|
||||
.description('drop account')
|
||||
|
||||
@@ -203,6 +203,15 @@ export async function createAccount (db: Db, email: string, password: string, fi
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export async function listWorkspaces (db: Db): Promise<Workspace[]> {
|
||||
return await db.collection<Workspace>(WORKSPACE_COLLECTION)
|
||||
.find({})
|
||||
.toArray()
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
@@ -299,7 +308,8 @@ export const methods = {
|
||||
createAccount: wrap(createAccount),
|
||||
createWorkspace: wrap(createWorkspace),
|
||||
assignWorkspace: wrap(assignWorkspace),
|
||||
removeWorkspace: wrap(removeWorkspace)
|
||||
removeWorkspace: wrap(removeWorkspace),
|
||||
listWorkspaces: wrap(listWorkspaces)
|
||||
// updateAccount: wrap(updateAccount)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user