diff --git a/src/collections/aggregate/integration.test.ts b/src/collections/aggregate/integration.test.ts index f06017c0..284606b6 100644 --- a/src/collections/aggregate/integration.test.ts +++ b/src/collections/aggregate/integration.test.ts @@ -39,7 +39,7 @@ describe('Testing of the collection.aggregate methods', () => { beforeAll(async () => { client = await weaviate.connectToLocal(); - collection = client.collections.get(collectionName); + collection = client.collections.use(collectionName); return client.collections .create({ name: collectionName, @@ -168,7 +168,7 @@ describe('Testing of the collection.aggregate methods', () => { }); it('should aggregate data without a search and one non-generic property metric', async () => { - const result = await (await client).collections.get(collectionName).aggregate.overAll({ + const result = await (await client).collections.use(collectionName).aggregate.overAll({ returnMetrics: collection.metrics .aggregate('text') .text(['count', 'topOccurrencesOccurs', 'topOccurrencesValue']), @@ -307,7 +307,7 @@ describe('Testing of the collection.aggregate methods with named vectors', () => beforeAll(async () => { client = await weaviate.connectToLocal(); - collection = client.collections.get(collectionName); + collection = client.collections.use(collectionName); const query = () => client.collections.create({ name: collectionName, @@ -355,7 +355,7 @@ describe('Testing of collection.aggregate.overAll with a multi-tenancy collectio beforeAll(async () => { client = await weaviate.connectToLocal(); - collection = client.collections.get(collectionName); + collection = client.collections.use(collectionName); return client.collections .create({ name: collectionName, @@ -407,7 +407,7 @@ describe('Testing of collection.aggregate search methods', () => { beforeAll(async () => { client = await weaviate.connectToLocal(); - collection = client.collections.get(collectionName); + collection = client.collections.use(collectionName); return client.collections .create({ name: collectionName, diff --git a/src/collections/backup/integration.test.ts b/src/collections/backup/integration.test.ts index 1eb65358..66b38b2d 100644 --- a/src/collections/backup/integration.test.ts +++ b/src/collections/backup/integration.test.ts @@ -11,7 +11,7 @@ describe('Integration testing of backups', () => { grpcPort: 50061, }); - const getCollection = (client: WeaviateClient) => client.collections.get('TestBackupCollection'); + const getCollection = (client: WeaviateClient) => client.collections.use('TestBackupCollection'); beforeAll(() => clientPromise.then((client) => diff --git a/src/collections/config/integration.test.ts b/src/collections/config/integration.test.ts index 254c6112..be729ea0 100644 --- a/src/collections/config/integration.test.ts +++ b/src/collections/config/integration.test.ts @@ -580,7 +580,7 @@ describe('Testing of the collection.config namespace', () => { vectorizer: 'none', }) .do(); - const collection = client.collections.get(collectionName); + const collection = client.collections.use(collectionName); const config = await collection.config .update({ vectorizers: weaviate.reconfigure.vectorizer.update({ @@ -631,7 +631,7 @@ describe('Testing of the collection.config namespace', () => { return; } const collectionName = 'TestCollectionConfigUpdateGenerative'; - const collection = client.collections.get(collectionName); + const collection = client.collections.use(collectionName); await client.collections.create({ name: collectionName, vectorizers: weaviate.configure.vectorizer.none(), diff --git a/src/collections/data/integration.test.ts b/src/collections/data/integration.test.ts index 3b55c64f..681609a2 100644 --- a/src/collections/data/integration.test.ts +++ b/src/collections/data/integration.test.ts @@ -40,7 +40,7 @@ describe('Testing of the collection.data methods with a single target reference' beforeAll(async () => { client = await weaviate.connectToLocal(); - collection = client.collections.get(collectionName); + collection = client.collections.use(collectionName); await client.collections .create({ name: collectionName, @@ -500,8 +500,8 @@ describe('Testing of the collection.data methods with a multi target reference', beforeAll(async () => { client = await weaviate.connectToLocal(); - collectionOne = client.collections.get(classNameOne); - collectionTwo = client.collections.get(classNameTwo); + collectionOne = client.collections.use(classNameOne); + collectionTwo = client.collections.use(classNameTwo); oneId = await client.collections .create({ name: classNameOne, @@ -1019,7 +1019,7 @@ describe('Testing of BYOV insertion with legacy vectorizer', () => { it('should insert and retrieve many vectors using the new client', async () => { const client = await weaviate.connectToLocal(); - const collection = client.collections.get(collectionName); + const collection = client.collections.use(collectionName); const { uuids, hasErrors } = await collection.data.insertMany([ { vectors: [1, 2, 3] }, { vectors: [4, 5, 6] }, @@ -1035,7 +1035,7 @@ describe('Testing of BYOV insertion with legacy vectorizer', () => { it('should insert and retrieve single vectors using the new client', async () => { const client = await weaviate.connectToLocal(); - const collection = client.collections.get(collectionName); + const collection = client.collections.use(collectionName); const id = await collection.data.insert({ vectors: [7, 8, 9] }); const object = await collection.query.fetchObjectById(id, { includeVector: true }); expect(object?.vectors.default).toEqual([7, 8, 9]); diff --git a/src/collections/filters/integration.test.ts b/src/collections/filters/integration.test.ts index abfbd8ba..d4a72d05 100644 --- a/src/collections/filters/integration.test.ts +++ b/src/collections/filters/integration.test.ts @@ -32,7 +32,7 @@ describe('Testing of the filter class with a simple collection', () => { beforeAll(async () => { client = await weaviate.connectToLocal(); - collection = client.collections.get(collectionName); + collection = client.collections.use(collectionName); ids = await client.collections .create({ name: collectionName, @@ -111,8 +111,8 @@ describe('Testing of the filter class with a simple collection', () => { }); it('should filter a fetch objects query with a single filter and non-generic collection', async () => { - const res = await client.collections.get(collectionName).query.fetchObjects({ - filters: client.collections.get(collectionName).filter.byProperty('text').equal('two'), + const res = await client.collections.use(collectionName).query.fetchObjects({ + filters: client.collections.use(collectionName).filter.byProperty('text').equal('two'), }); expect(res.objects.length).toEqual(1); const obj = res.objects[0]; @@ -295,7 +295,7 @@ describe('Testing of the filter class with complex data types', () => { beforeAll(async () => { client = await weaviate.connectToLocal(); - collection = client.collections.get(collectionName); + collection = client.collections.use(collectionName); await client.collections .create({ name: collectionName, diff --git a/src/collections/generate/integration.test.ts b/src/collections/generate/integration.test.ts index 1be98451..41846f90 100644 --- a/src/collections/generate/integration.test.ts +++ b/src/collections/generate/integration.test.ts @@ -42,7 +42,7 @@ maybe('Testing of the collection.generate methods with a simple collection', () beforeAll(async () => { client = await makeOpenAIClient(); - collection = client.collections.get(collectionName); + collection = client.collections.use(collectionName); id = await client.collections .create({ name: collectionName, @@ -70,7 +70,7 @@ maybe('Testing of the collection.generate methods with a simple collection', () describe('using a non-generic collection', () => { it('should generate without search', async () => { - const ret = await client.collections.get(collectionName).generate.fetchObjects({ + const ret = await client.collections.use(collectionName).generate.fetchObjects({ singlePrompt: 'Write a haiku about ducks for {testProp}', groupedTask: 'What is the value of testProp here?', groupedProperties: ['testProp'], @@ -183,7 +183,7 @@ maybe('Testing of the groupBy collection.generate methods with a simple collecti beforeAll(async () => { client = await makeOpenAIClient(); - collection = client.collections.get(collectionName); + collection = client.collections.use(collectionName); id = await client.collections .create({ name: collectionName, @@ -331,7 +331,7 @@ maybe('Testing of the collection.generate methods with a multi vector collection beforeAll(async () => { client = await makeOpenAIClient(); - collection = client.collections.get(collectionName); + collection = client.collections.use(collectionName); const query = () => client.collections .create({ diff --git a/src/collections/index.ts b/src/collections/index.ts index 0472c459..b5c2edb5 100644 --- a/src/collections/index.ts +++ b/src/collections/index.ts @@ -276,6 +276,9 @@ const collections = (connection: Connection, dbVersionSupport: DbVersionSupport) get: ( name: TName ) => collection(connection, name, dbVersionSupport), + use: ( + name: TName + ) => collection(connection, name, dbVersionSupport), }; }; @@ -292,9 +295,9 @@ export interface Collections { name: TName ): Collection; listAll(): Promise; - // use( - // name: TName - // ): Collection; + use( + name: TName + ): Collection; } export default collections; diff --git a/src/collections/integration.test.ts b/src/collections/integration.test.ts index bd6512fe..f143843d 100644 --- a/src/collections/integration.test.ts +++ b/src/collections/integration.test.ts @@ -77,7 +77,7 @@ describe('Testing of the collections.create method', () => { }, ], }) - .then(() => contextionary.collections.get(collectionName).config.get()); + .then(() => contextionary.collections.use(collectionName).config.get()); expect(response.name).toEqual(collectionName); expect(response.properties?.length).toEqual(1); expect(response.properties[0].name).toEqual('testProp'); @@ -166,7 +166,7 @@ describe('Testing of the collections.create method', () => { .create({ name: collectionName, }) - .then(() => contextionary.collections.get(collectionName).config.get()); + .then(() => contextionary.collections.use(collectionName).config.get()); expect(response.name).toEqual(collectionName); expect(response.properties?.length).toEqual(0); expect(response.vectorizers.default.indexConfig).toBeDefined(); @@ -188,7 +188,7 @@ describe('Testing of the collections.create method', () => { const response = await contextionary.collections .create(schema) .then(async (collection) => expect(await collection.exists()).toEqual(true)) - .then(() => contextionary.collections.get(collectionName).config.get()); + .then(() => contextionary.collections.use(collectionName).config.get()); expect(response.name).toEqual(collectionName); expect(response.properties?.length).toEqual(1); expect(response.properties[0].name).toEqual('testProp'); @@ -525,7 +525,7 @@ describe('Testing of the collections.create method', () => { }), }) .then(async (collection) => expect(await collection.exists()).toEqual(true)) - .then(() => cluster.collections.get(collectionName).config.get()); + .then(() => cluster.collections.use(collectionName).config.get()); expect(response.name).toEqual(collectionName); expect(response.description).toEqual('A test collection'); @@ -628,7 +628,7 @@ describe('Testing of the collections.create method', () => { vectorizers: weaviate.configure.vectorizer.text2VecContextionary(), }) .then(async (collection) => expect(await collection.exists()).toEqual(true)) - .then(() => contextionary.collections.get(collectionName).config.get()); + .then(() => contextionary.collections.use(collectionName).config.get()); expect(response.name).toEqual(collectionName); expect(response.properties?.length).toEqual(1); expect(response.properties?.[0].name).toEqual('testProp'); @@ -656,7 +656,7 @@ describe('Testing of the collections.create method', () => { vectorizers: weaviate.configure.vectorizer.text2VecOpenAI(), }) .then(async (collection) => expect(await collection.exists()).toEqual(true)) - .then(() => openai.collections.get(collectionName).config.get()); + .then(() => openai.collections.use(collectionName).config.get()); expect(response.name).toEqual(collectionName); expect(response.properties?.length).toEqual(1); expect(response.properties?.[0].name).toEqual('testProp'); @@ -684,7 +684,7 @@ describe('Testing of the collections.create method', () => { generative: weaviate.configure.generative.openAI(), }) .then(async (collection) => expect(await collection.exists()).toEqual(true)) - .then(() => openai.collections.get(collectionName).config.get()); + .then(() => openai.collections.use(collectionName).config.get()); expect(response.name).toEqual(collectionName); expect(response.properties?.length).toEqual(1); expect(response.properties?.[0].name).toEqual('testProp'); diff --git a/src/collections/iterator/integration.test.ts b/src/collections/iterator/integration.test.ts index 6937b270..c4757083 100644 --- a/src/collections/iterator/integration.test.ts +++ b/src/collections/iterator/integration.test.ts @@ -23,7 +23,7 @@ describe('Testing of the collection.iterator method with a simple collection', ( beforeAll(async () => { client = await weaviate.connectToLocal({ port: 8080, grpcPort: 50051 }); - collection = client.collections.get(collectionName); + collection = client.collections.use(collectionName); id = await client.collections .create({ name: collectionName, diff --git a/src/collections/query/integration.test.ts b/src/collections/query/integration.test.ts index 49a2e236..09698c05 100644 --- a/src/collections/query/integration.test.ts +++ b/src/collections/query/integration.test.ts @@ -27,7 +27,7 @@ describe('Testing of the collection.query methods with a simple collection', () beforeAll(async () => { client = await weaviate.connectToLocal(); - collection = client.collections.get(collectionName); + collection = client.collections.use(collectionName); id = await client.collections .create({ name: collectionName, @@ -111,7 +111,7 @@ describe('Testing of the collection.query methods with a simple collection', () }); it('should query with bm25 and weighted query properties with a non-generic collection', async () => { - const ret = await client.collections.get(collectionName).query.bm25('carrot', { + const ret = await client.collections.use(collectionName).query.bm25('carrot', { queryProperties: [ { name: 'testProp', @@ -230,7 +230,7 @@ describe('Testing of the collection.query methods with a collection with a refer beforeAll(async () => { client = await weaviate.connectToLocal(); - collection = client.collections.get(collectionName); + collection = client.collections.use(collectionName); return client.collections .create({ name: collectionName, @@ -270,7 +270,7 @@ describe('Testing of the collection.query methods with a collection with a refer describe('using a non-generic collection', () => { it('should query without searching returning the referenced object', async () => { - const ret = await client.collections.get(collectionName).query.fetchObjects({ + const ret = await client.collections.use(collectionName).query.fetchObjects({ returnProperties: ['testProp'], returnReferences: [ { @@ -450,7 +450,7 @@ describe('Testing of the collection.query methods with a collection with a neste beforeAll(async () => { client = await weaviate.connectToLocal(); - collection = client.collections.get(collectionName); + collection = client.collections.use(collectionName); return client.collections .create({ name: collectionName, @@ -575,7 +575,7 @@ describe('Testing of the collection.query methods with a collection with a multi beforeAll(async () => { client = await weaviate.connectToLocal(); - collection = client.collections.get(collectionName); + collection = client.collections.use(collectionName); const query = () => client.collections .create({ @@ -1085,7 +1085,7 @@ describe('Testing of the groupBy collection.query methods with a simple collecti beforeAll(async () => { client = await weaviate.connectToLocal(); - collection = client.collections.get(collectionName); + collection = client.collections.use(collectionName); id = await client.collections .create({ name: collectionName, @@ -1207,7 +1207,7 @@ describe('Testing of the groupBy collection.query methods with a simple collecti }); it('should groupBy with nearVector and a non-generic collection', async () => { - const ret = await client.collections.get(collectionName).query.nearVector(vector, { + const ret = await client.collections.use(collectionName).query.nearVector(vector, { groupBy: { numberOfGroups: 1, objectsPerGroup: 1, @@ -1246,7 +1246,7 @@ describe('Testing of the collection.query methods with a multi-tenancy collectio beforeAll(async () => { client = await weaviate.connectToLocal(); - collection = client.collections.get(collectionName); + collection = client.collections.use(collectionName); [id1, id2] = await client.collections .create({ name: collectionName, @@ -1394,7 +1394,7 @@ describe('Testing of the collection.query methods with a multi-tenancy collectio // 'X-OpenAI-Api-Key': process.env.OPENAI_APIKEY as string, // }, // }); -// collection = client.collections.get(collectionName); +// collection = client.collections.use(collectionName); // [id1, id2] = await client.collections // .create({ // name: collectionName, diff --git a/src/collections/sort/integration.test.ts b/src/collections/sort/integration.test.ts index d4b2e9c7..8800ee2c 100644 --- a/src/collections/sort/integration.test.ts +++ b/src/collections/sort/integration.test.ts @@ -34,8 +34,8 @@ describe('Testing of the Sort class with a simple collection', () => { beforeAll(async () => { client = await weaviate.connectToLocal(); - collection = client.collections.get(collectionName); - collections = [collection, client.collections.get(collectionName)]; + collection = client.collections.use(collectionName); + collections = [collection, client.collections.use(collectionName)]; ids = await client.collections .create({ name: collectionName, diff --git a/src/collections/tenants/integration.test.ts b/src/collections/tenants/integration.test.ts index 4cfb184e..b574759a 100644 --- a/src/collections/tenants/integration.test.ts +++ b/src/collections/tenants/integration.test.ts @@ -17,7 +17,7 @@ describe('Testing of the collection.tenants methods', () => { beforeAll(async () => { client = await weaviate.connectToLocal(); - collection = client.collections.get(collectionName); + collection = client.collections.use(collectionName); return client.collections .create({ name: collectionName, diff --git a/src/collections/tenants/unit.test.ts b/src/collections/tenants/unit.test.ts index a697e550..6b160bf1 100644 --- a/src/collections/tenants/unit.test.ts +++ b/src/collections/tenants/unit.test.ts @@ -82,7 +82,7 @@ describe('Mock testing of tenants.get() method with a REST server', () => { it('should get mocked tenants', async () => { const client = await weaviate.connectToLocal({ port: 8954, grpcPort: 8955 }); - const collection = client.collections.get(TENANTS_COLLECTION_NAME); + const collection = client.collections.use(TENANTS_COLLECTION_NAME); const tenants = await collection.tenants.get(); expect(tenants).toEqual>({ hot: { name: 'hot', activityStatus: 'ACTIVE' }, @@ -108,7 +108,7 @@ describe('Mock testing of tenants.get() method with a gRPC server', () => { it('should get the mocked tenants', async () => { const client = await weaviate.connectToLocal({ port: 8956, grpcPort: 8957 }); - const collection = client.collections.get(TENANTS_COLLECTION_NAME); + const collection = client.collections.use(TENANTS_COLLECTION_NAME); const tenants = await collection.tenants.get(); expect(tenants).toEqual>({ hot: { name: 'hot', activityStatus: 'ACTIVE' }, diff --git a/src/connection/unit.test.ts b/src/connection/unit.test.ts index ab88c586..3ead6a88 100644 --- a/src/connection/unit.test.ts +++ b/src/connection/unit.test.ts @@ -314,7 +314,7 @@ describe('Mock testing of timeout behaviour', () => { beforeAll(async () => { servers = await makeMockServers('1.29.0', 8954, 'localhost:8955'); client = await weaviate.connectToLocal({ port: 8954, grpcPort: 8955, timeout: { query: 1, insert: 1 } }); - collection = client.collections.get(COLLECTION_NAME); + collection = client.collections.use(COLLECTION_NAME); }); it('should timeout when calling REST GET v1/schema', () =>