feat: add uuid to account ids
This commit is contained in:
15
package-lock.json
generated
15
package-lock.json
generated
@@ -1346,6 +1346,15 @@
|
||||
"integrity": "sha512-7NQmHra/JILCd1QqpSzl8+mJRc8ZHz3uDm8YV1Ks9IhK0epEiTw8aIErbvH9PI+6XbqhyIQy3462nEsn7UVzjQ==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/uuid": {
|
||||
"version": "3.4.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-3.4.5.tgz",
|
||||
"integrity": "sha512-MNL15wC3EKyw1VLF+RoVO4hJJdk9t/Hlv3rt1OL65Qvuadm4BYo6g9ZJQqoq7X8NBFSsQXgAujWciovh2lpVjA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"@types/webpack-env": {
|
||||
"version": "1.14.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/webpack-env/-/webpack-env-1.14.0.tgz",
|
||||
@@ -15175,9 +15184,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"uuid": {
|
||||
"version": "3.3.2",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz",
|
||||
"integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA=="
|
||||
"version": "3.3.3",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.3.tgz",
|
||||
"integrity": "sha512-pW0No1RGHgzlpHJO1nsVrHKpOEIxkGg1xB+v0ZmdNH5OAeAwzAVrCnI2/6Mtx+Uys6iaylxa+D3g4j63IKKjSQ=="
|
||||
},
|
||||
"validate-npm-package-license": {
|
||||
"version": "3.0.4",
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
"pouchdb-authentication": "^1.1.3",
|
||||
"pouchdb-browser": "^7.1.1",
|
||||
"register-service-worker": "^1.6.2",
|
||||
"uuid": "^3.3.3",
|
||||
"vue": "^2.6.10",
|
||||
"vue-class-component": "^7.1.0",
|
||||
"vue-click-outside": "^1.0.7",
|
||||
@@ -43,6 +44,7 @@
|
||||
"@types/md5": "^2.1.33",
|
||||
"@types/notyf": "^2.0.0",
|
||||
"@types/pouchdb": "^6.4.0",
|
||||
"@types/uuid": "^3.4.5",
|
||||
"@vue/cli-plugin-babel": "^3.10.0",
|
||||
"@vue/cli-plugin-pwa": "^3.10.0",
|
||||
"@vue/cli-plugin-typescript": "^3.10.0",
|
||||
|
||||
@@ -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