use underscores instead of colons, shorten id entity names
This commit is contained in:
parent
4fa3b9c473
commit
954f6ad47b
|
@ -1,13 +1,13 @@
|
||||||
const newid = require("./newid")
|
const newid = require("./newid")
|
||||||
|
|
||||||
const DocumentTypes = {
|
const DocumentTypes = {
|
||||||
MODEL: "model",
|
MODEL: "mo",
|
||||||
RECORD: "record",
|
RECORD: "re",
|
||||||
USER: "user",
|
USER: "us",
|
||||||
AUTOMATION: "automation",
|
AUTOMATION: "au",
|
||||||
LINK: "link",
|
LINK: "li",
|
||||||
APP: "app",
|
APP: "app",
|
||||||
ACCESS_LEVEL: "accesslevel",
|
ACCESS_LEVEL: "ac",
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.DocumentTypes = DocumentTypes
|
exports.DocumentTypes = DocumentTypes
|
||||||
|
@ -32,8 +32,8 @@ function getDocParams(docType, docId = null, otherProps = {}) {
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
...otherProps,
|
...otherProps,
|
||||||
startkey: `${docType}:${docId}`,
|
startkey: `${docType}_${docId}`,
|
||||||
endkey: `${docType}:${docId}${UNICODE_MAX}`,
|
endkey: `${docType}_${docId}${UNICODE_MAX}`,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ exports.getModelParams = (modelId = null, otherProps = {}) => {
|
||||||
* @returns {string} The new model ID which the model doc can be stored under.
|
* @returns {string} The new model ID which the model doc can be stored under.
|
||||||
*/
|
*/
|
||||||
exports.generateModelID = () => {
|
exports.generateModelID = () => {
|
||||||
return `${DocumentTypes.MODEL}:${newid()}`
|
return `${DocumentTypes.MODEL}_${newid()}`
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -64,7 +64,7 @@ exports.getRecordParams = (modelId, recordId = null, otherProps = {}) => {
|
||||||
if (modelId == null) {
|
if (modelId == null) {
|
||||||
throw "Cannot build params for records without a model ID"
|
throw "Cannot build params for records without a model ID"
|
||||||
}
|
}
|
||||||
const endOfKey = recordId == null ? `${modelId}:` : `${modelId}:${recordId}`
|
const endOfKey = recordId == null ? `${modelId}_` : `${modelId}_${recordId}`
|
||||||
return getDocParams(DocumentTypes.RECORD, endOfKey, otherProps)
|
return getDocParams(DocumentTypes.RECORD, endOfKey, otherProps)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ exports.getRecordParams = (modelId, recordId = null, otherProps = {}) => {
|
||||||
* @returns {string} The new ID which a record doc can be stored under.
|
* @returns {string} The new ID which a record doc can be stored under.
|
||||||
*/
|
*/
|
||||||
exports.generateRecordID = modelId => {
|
exports.generateRecordID = modelId => {
|
||||||
return `${DocumentTypes.RECORD}:${modelId}:${newid()}`
|
return `${DocumentTypes.RECORD}_${modelId}_${newid()}`
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -90,7 +90,7 @@ exports.getUserParams = (username = null, otherProps = {}) => {
|
||||||
* @returns {string} The new user ID which the user doc can be stored under.
|
* @returns {string} The new user ID which the user doc can be stored under.
|
||||||
*/
|
*/
|
||||||
exports.generateUserID = username => {
|
exports.generateUserID = username => {
|
||||||
return `${DocumentTypes.USER}:${username}`
|
return `${DocumentTypes.USER}_${username}`
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -105,7 +105,7 @@ exports.getAutomationParams = (automationId = null, otherProps = {}) => {
|
||||||
* @returns {string} The new automation ID which the automation doc can be stored under.
|
* @returns {string} The new automation ID which the automation doc can be stored under.
|
||||||
*/
|
*/
|
||||||
exports.generateAutomationID = () => {
|
exports.generateAutomationID = () => {
|
||||||
return `${DocumentTypes.AUTOMATION}:${newid()}`
|
return `${DocumentTypes.AUTOMATION}_${newid()}`
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -118,7 +118,7 @@ exports.generateAutomationID = () => {
|
||||||
* @returns {string} The new link doc ID which the automation doc can be stored under.
|
* @returns {string} The new link doc ID which the automation doc can be stored under.
|
||||||
*/
|
*/
|
||||||
exports.generateLinkID = (modelId1, modelId2, recordId1, recordId2) => {
|
exports.generateLinkID = (modelId1, modelId2, recordId1, recordId2) => {
|
||||||
return `${DocumentTypes.AUTOMATION}:${modelId1}:${modelId2}:${recordId1}:${recordId2}`
|
return `${DocumentTypes.AUTOMATION}_${modelId1}_${modelId2}_${recordId1}_${recordId2}`
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -126,7 +126,7 @@ exports.generateLinkID = (modelId1, modelId2, recordId1, recordId2) => {
|
||||||
* @returns {string} The new app ID which the app doc can be stored under.
|
* @returns {string} The new app ID which the app doc can be stored under.
|
||||||
*/
|
*/
|
||||||
exports.generateAppID = () => {
|
exports.generateAppID = () => {
|
||||||
return `${DocumentTypes.APP}:${newid()}`
|
return `${DocumentTypes.APP}_${newid()}`
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -141,7 +141,7 @@ exports.getAppParams = (appId = null, otherProps = {}) => {
|
||||||
* @returns {string} The new access level ID which the access level doc can be stored under.
|
* @returns {string} The new access level ID which the access level doc can be stored under.
|
||||||
*/
|
*/
|
||||||
exports.generateAccessLevelID = () => {
|
exports.generateAccessLevelID = () => {
|
||||||
return `${DocumentTypes.ACCESS_LEVEL}:${newid()}`
|
return `${DocumentTypes.ACCESS_LEVEL}_${newid()}`
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue