34 lines
1013 B
TypeScript
34 lines
1013 B
TypeScript
|
|
import 'dotenv/config';
|
||
|
|
import chalk from 'chalk';
|
||
|
|
import util from 'node:util';
|
||
|
|
import { client } from '../src/db/typesense.ts';
|
||
|
|
|
||
|
|
const variants = [
|
||
|
|
'$skus(*, $cards(*))',
|
||
|
|
'$skus(*,$cards(*))',
|
||
|
|
'$skus(*, card_id, $cards(*))',
|
||
|
|
'$skus(*, $cards(*, strategy:nest))',
|
||
|
|
'$skus(*, $cards(*, strategy:merge))',
|
||
|
|
];
|
||
|
|
|
||
|
|
const debug = await client.debug.retrieve();
|
||
|
|
console.log(chalk.cyan(`Typesense server version: ${debug.version}`));
|
||
|
|
console.log();
|
||
|
|
|
||
|
|
for (const include of variants) {
|
||
|
|
console.log(chalk.yellow(`include_fields: ${include}`));
|
||
|
|
try {
|
||
|
|
const res: any = await client.collections('inventories').documents().search({
|
||
|
|
q: '*',
|
||
|
|
query_by: 'content',
|
||
|
|
per_page: 1,
|
||
|
|
include_fields: include,
|
||
|
|
});
|
||
|
|
const doc = res.hits?.[0]?.document;
|
||
|
|
console.log(util.inspect(doc, { depth: null, colors: false }));
|
||
|
|
} catch (err: any) {
|
||
|
|
console.log(chalk.red(` ERROR: ${err.message ?? err}`));
|
||
|
|
}
|
||
|
|
console.log();
|
||
|
|
}
|