feature: allow organizing by id within symlink indexes
This commit is contained in:
parent
02a518667b
commit
77765e9e60
2 changed files with 19 additions and 8 deletions
20
deno.json
20
deno.json
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@andyburke/fsdb",
|
||||
"version": "1.1.0",
|
||||
"version": "1.2.0",
|
||||
"license": "MIT",
|
||||
"exports": {
|
||||
".": "./fsdb.ts",
|
||||
|
|
@ -8,16 +8,16 @@
|
|||
"./indexers": "./indexers.ts",
|
||||
"./organizers": "./organizers.ts"
|
||||
},
|
||||
|
||||
"tasks": {
|
||||
"lint": "deno lint",
|
||||
"fmt": "deno fmt",
|
||||
"test": "cd tests && DENO_ENV=test FSDB_TEST_DATA_STORAGE_ROOT=./data/$(date --iso-8601=seconds) deno test --allow-env --allow-read --allow-write --fail-fast --trace-leaks ./",
|
||||
"fsdb": "deno run --allow-env --allow-read --allow-write cli.ts"
|
||||
},
|
||||
|
||||
"fmt": {
|
||||
"include": ["**/*.ts"],
|
||||
"include": [
|
||||
"**/*.ts"
|
||||
],
|
||||
"options": {
|
||||
"useTabs": true,
|
||||
"lineWidth": 140,
|
||||
|
|
@ -28,10 +28,16 @@
|
|||
}
|
||||
},
|
||||
"lint": {
|
||||
"include": ["**/*.ts"],
|
||||
"include": [
|
||||
"**/*.ts"
|
||||
],
|
||||
"rules": {
|
||||
"tags": ["recommended"],
|
||||
"exclude": ["no-explicit-any"]
|
||||
"tags": [
|
||||
"recommended"
|
||||
],
|
||||
"exclude": [
|
||||
"no-explicit-any"
|
||||
]
|
||||
}
|
||||
},
|
||||
"imports": {
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ interface FSDB_INDEXER_SYMLINKS_CONFIG_SHARED {
|
|||
id_field?: string;
|
||||
to_many?: boolean;
|
||||
organize?: (value: string) => string[];
|
||||
organize_id?: (value: string) => string[];
|
||||
}
|
||||
|
||||
interface FSDB_INDEXER_SYMLINKS_CONFIG_WITH_FIELD extends FSDB_INDEXER_SYMLINKS_CONFIG_SHARED {
|
||||
|
|
@ -191,7 +192,11 @@ export class FSDB_INDEXER_SYMLINKS<T> implements FSDB_INDEXER<T> {
|
|||
continue;
|
||||
}
|
||||
|
||||
organized_paths.push(`${item_id}.json`);
|
||||
if (this.config.organize_id) {
|
||||
organized_paths.push(...this.config.organize_id(item_id));
|
||||
} else {
|
||||
organized_paths.push(`${item_id}.json`);
|
||||
}
|
||||
}
|
||||
|
||||
const symlink_path = path.resolve(path.join(this.config.root, ...organized_paths));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue