diff --git a/examples/embedded/index.ts b/examples/embedded/index.ts index 6b48c7fa..34478729 100644 --- a/examples/embedded/index.ts +++ b/examples/embedded/index.ts @@ -1,21 +1,45 @@ import weaviate from 'weaviate-ts-client'; -// EmbeddedDB only supports Linux. Try me in a docker container! -if (process.platform == 'linux') { - const client = weaviate.client({ - scheme: 'http', - host: 'localhost:9898', - embedded: new weaviate.EmbeddedOptions({ - port: 9898, - }), - }); - - await client.embedded?.start(); - - client.misc - .metaGetter() - .do() - .then((res: any) => console.log(`res: ${JSON.stringify(res)}`)); - - client.embedded?.stop(); +if (process.platform !== 'linux') { + throw new Error( + 'EmbeddedDB only supports Linux at the moment. Try me in a Docker container!' + ); } + +const client = weaviate.client({ + scheme: 'http', + host: 'localhost:9898', + embedded: new weaviate.EmbeddedOptions({ + port: 9898, + }), +}); + +console.log('Weaviate binary:', client.embedded?.options.binaryPath); +console.log('Data path:', client.embedded?.options.persistenceDataPath); + +await client.embedded?.start(); + +console.info('\nEmbedded DB started\n'); + +// Create object with autoschema +const result = await client.data + .creator() + .withClassName('Wine') + .withProperties({ + name: 'Pinot noir', + description: 'Smooth taste', + }) + .do(); +console.log(result); + +// Dump all objects +const objects = await client.data.getter().do(); +console.log(objects); + +// Dump metadata +const metadata = await client.misc.metaGetter().do(); +console.log(metadata); + +console.info('\nStopping...'); +client.embedded?.stop(); +console.info('Exiting...');