feat: add uuid to account ids

This commit is contained in:
Julien Calixte
2019-08-27 00:28:05 +02:00
parent ee74bf3276
commit 7a3f168218
4 changed files with 18 additions and 6 deletions

View File

@@ -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)

View File

@@ -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> {