feat: add uuid to account ids
This commit is contained in:
@@ -26,7 +26,7 @@ class AccountService {
|
||||
public async add(account: IAccount): Promise<PouchDB.Core.Response> {
|
||||
try {
|
||||
account.slug = slug(account.name)
|
||||
const id = couchService.newId('acc')
|
||||
const id = couchService.newId('acc', true)
|
||||
account._id = id
|
||||
account.doctype = 'account'
|
||||
const response = await couchService.save(account)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import axios from 'axios'
|
||||
import uuid from 'uuid/v4'
|
||||
import PouchDb from 'pouchdb-browser'
|
||||
import PouchDbAuthentication from 'pouchdb-authentication'
|
||||
import bus, { SYNC } from '@/utils/bus-event'
|
||||
@@ -340,8 +341,8 @@ class CouchService {
|
||||
return false
|
||||
}
|
||||
|
||||
public newId(...prefixes: string[]): string {
|
||||
return `${prefixes.join('-')}${Date.now().toString()}`
|
||||
public newId(prefix: string, withUuid: boolean = false): string {
|
||||
return `${prefix}${Date.now().toString()}${withUuid ? uuid() : ''}`
|
||||
}
|
||||
|
||||
public async purgeDb(): Promise<void> {
|
||||
|
||||
Reference in New Issue
Block a user