diff --git a/deno.json b/deno.json index 6f63ca6..c05c8bb 100644 --- a/deno.json +++ b/deno.json @@ -1,6 +1,6 @@ { "name": "@andyburke/fsdb", - "version": "1.0.3", + "version": "1.0.4", "license": "MIT", "exports": { ".": "./fsdb.ts", diff --git a/fsdb.ts b/fsdb.ts index a5e66de..db70716 100644 --- a/fsdb.ts +++ b/fsdb.ts @@ -7,51 +7,51 @@ * import { FSDB_INDEXER_SYMLINKS } from '@andyburke/fsdb/indexers'; * import { by_character, by_email, by_phone } from '@andyburke/fsdb/organizers'; * - * type ITEM = { - * id: string; - * email: string; - * phone: string; - * value: string; - * }; + * type ITEM = { + * id: string; + * email: string; + * phone: string; + * value: string; + * }; * - * const item_collection: fsdb.FSDB_COLLECTION = new fsdb.FSDB_COLLECTION({ - * name: 'test-03-items', - * root: get_data_dir() + '/test-03-items', - * indexers: { - * email: new FSDB_INDEXER_SYMLINKS({ - * name: 'email', - * field: 'email', - * organize: by_email - * }), - * phone: new FSDB_INDEXER_SYMLINKS({ - * name: 'phone', - * field: 'phone', - * organize: by_phone - * }), - * value: new FSDB_INDEXER_SYMLINKS({ - * name: 'value', - * organize: by_character, - * get_values_to_index: (item: ITEM) => item.value.split(/\W/).filter((word) => word.length > 3), - * to_many: true - * }) - * } - * }); + * const item_collection: fsdb.FSDB_COLLECTION = new fsdb.FSDB_COLLECTION({ + * name: 'test-03-items', + * root: get_data_dir() + '/test-03-items', + * indexers: { + * email: new FSDB_INDEXER_SYMLINKS({ + * name: 'email', + * field: 'email', + * organize: by_email + * }), + * phone: new FSDB_INDEXER_SYMLINKS({ + * name: 'phone', + * field: 'phone', + * organize: by_phone + * }), + * value: new FSDB_INDEXER_SYMLINKS({ + * name: 'value', + * organize: by_character, + * get_values_to_index: (item: ITEM) => item.value.split(/\W/).filter((word) => word.length > 3), + * to_many: true + * }) + * } + * }); * - * const item = { - * id: lurid(), - * email: random_email_address(), - * phone: random_phone_number(), - * value: random_sentence() - * }; + * const item = { + * id: lurid(), + * email: random_email_address(), + * phone: random_phone_number(), + * value: random_sentence() + * }; * - * const stored_item: ITEM = await item_collection.create(item); - * const fetched_by_email: ITEM = (await item_collection.find({ email: item.email })).map((entry) => entry.load()).shift(); - * const fetched_by_phone: ITEM = (await item_collection.find({ phone: item.phone })).map((entry) => entry.load()).shift(); - * const fetched_by_word_in_value: ITEM = (await item_collection.find({ value: word })).map((entry) => entry.load()).shift(); + * const stored_item: ITEM = await item_collection.create(item); + * const fetched_by_email: ITEM = (await item_collection.find({ email: item.email })).map((entry) => entry.load()).shift(); + * const fetched_by_phone: ITEM = (await item_collection.find({ phone: item.phone })).map((entry) => entry.load()).shift(); + * const fetched_by_word_in_value: ITEM = (await item_collection.find({ value: word })).map((entry) => entry.load()).shift(); * ``` * * @module -*/ + */ import * as fs from '@std/fs'; import * as path from '@std/path'; diff --git a/indexers/symlinks.ts b/indexers/symlinks.ts index 5554095..200c9a6 100644 --- a/indexers/symlinks.ts +++ b/indexers/symlinks.ts @@ -230,6 +230,10 @@ export class FSDB_INDEXER_SYMLINKS implements FSDB_INDEXER { const item_dir: string = path.dirname(item_path); for (const value of values) { + if (typeof value === 'undefined') { + continue; + } + const item_dir_reverse_link: string = path.join(item_dir, `.index.symlink.${this.config.name}.${sanitize(value)}`); if (!fs.existsSync(item_dir_reverse_link)) { continue;