Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/collections/aggregate/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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']),
Expand Down Expand Up @@ -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<TestCollectionAggregateVectors>({
name: collectionName,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/collections/backup/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>
Expand Down
4 changes: 2 additions & 2 deletions src/collections/config/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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(),
Expand Down
10 changes: 5 additions & 5 deletions src/collections/data/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<TestCollectionData>({
name: collectionName,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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] },
Expand All @@ -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]);
Expand Down
8 changes: 4 additions & 4 deletions src/collections/filters/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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<TestCollectionFilterComplex>({
name: collectionName,
Expand Down
8 changes: 4 additions & 4 deletions src/collections/generate/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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'],
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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({
Expand Down
9 changes: 6 additions & 3 deletions src/collections/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,9 @@ const collections = (connection: Connection, dbVersionSupport: DbVersionSupport)
get: <TProperties extends Properties | undefined = undefined, TName extends string = string>(
name: TName
) => collection<TProperties, TName>(connection, name, dbVersionSupport),
use: <TProperties extends Properties | undefined = undefined, TName extends string = string>(
name: TName
) => collection<TProperties, TName>(connection, name, dbVersionSupport),
};
};

Expand All @@ -292,9 +295,9 @@ export interface Collections {
name: TName
): Collection<TProperties, TName>;
listAll(): Promise<CollectionConfig[]>;
// use<TProperties extends Properties | undefined = undefined, TName extends string = string>(
// name: TName
// ): Collection<TProperties, TName>;
use<TProperties extends Properties | undefined = undefined, TName extends string = string>(
name: TName
): Collection<TProperties, TName>;
}

export default collections;
Expand Down
14 changes: 7 additions & 7 deletions src/collections/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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();
Expand All @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion src/collections/iterator/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
20 changes: 10 additions & 10 deletions src/collections/query/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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: [
{
Expand Down Expand Up @@ -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<TestCollectionQueryWithNestedProps>({
name: collectionName,
Expand Down Expand Up @@ -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<TestCollectionQueryWithMultiVector>({
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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<TestCollectionMultiTenancy>({
name: collectionName,
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/collections/sort/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/collections/tenants/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/collections/tenants/unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Record<string, Tenant>>({
hot: { name: 'hot', activityStatus: 'ACTIVE' },
Expand All @@ -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<Record<string, Tenant>>({
hot: { name: 'hot', activityStatus: 'ACTIVE' },
Expand Down
Loading
Loading