New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

vectordb

Package Overview
Dependencies
Maintainers
5
Versions
100
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vectordb - npm Package Compare versions

Comparing version 0.4.8 to 0.4.9

17

dist/index.d.ts

@@ -217,3 +217,3 @@ import { type Schema, Table as ArrowTable } from 'apache-arrow';

*/
countRows: () => Promise<number>;
countRows: (filter?: string) => Promise<number>;
/**

@@ -359,4 +359,15 @@ * Delete rows from this table.

* but that behavior is subject to change.
*
* Optionally, a filter can be specified. This should be an SQL
* filter where fields with the prefix "target." refer to fields
* in the target table (old data) and fields with the prefix
* "source." refer to fields in the source table (new data). For
* example, the filter "target.lastUpdated < source.lastUpdated" will
* only update matched rows when the incoming `lastUpdated` value is
* newer.
*
* Rows that do not match the filter will not be updated. Rows that
* do not match the filter do become "not matched" rows.
*/
whenMatchedUpdateAll?: boolean;
whenMatchedUpdateAll?: string | boolean;
/**

@@ -473,3 +484,3 @@ * If true then rows that exist only in the source table (new data)

*/
countRows(): Promise<number>;
countRows(filter?: string): Promise<number>;
/**

@@ -476,0 +487,0 @@ * Delete rows from this table.

15

dist/index.js

@@ -242,4 +242,4 @@ "use strict";

*/
async countRows() {
return tableCountRows.call(this._tbl);
async countRows(filter) {
return tableCountRows.call(this._tbl, filter);
}

@@ -284,3 +284,10 @@ /**

async mergeInsert(on, data, args) {
const whenMatchedUpdateAll = args.whenMatchedUpdateAll ?? false;
let whenMatchedUpdateAll = false;
let whenMatchedUpdateAllFilt = null;
if (args.whenMatchedUpdateAll !== undefined && args.whenMatchedUpdateAll !== null) {
whenMatchedUpdateAll = true;
if (args.whenMatchedUpdateAll !== true) {
whenMatchedUpdateAllFilt = args.whenMatchedUpdateAll;
}
}
const whenNotMatchedInsertAll = args.whenNotMatchedInsertAll ?? false;

@@ -304,3 +311,3 @@ let whenNotMatchedBySourceDelete = false;

const buffer = await (0, arrow_1.fromTableToBuffer)(tbl, this._embeddings, schema);
this._tbl = await tableMergeInsert.call(this._tbl, on, whenMatchedUpdateAll, whenNotMatchedInsertAll, whenNotMatchedBySourceDelete, whenNotMatchedBySourceDeleteFilt, buffer);
this._tbl = await tableMergeInsert.call(this._tbl, on, whenMatchedUpdateAll, whenMatchedUpdateAllFilt, whenNotMatchedInsertAll, whenNotMatchedBySourceDelete, whenNotMatchedBySourceDeleteFilt, buffer);
}

@@ -307,0 +314,0 @@ /**

@@ -196,4 +196,7 @@ "use strict";

};
if (args.whenMatchedUpdateAll ?? false) {
if (args.whenMatchedUpdateAll !== false && args.whenMatchedUpdateAll !== null && args.whenMatchedUpdateAll !== undefined) {
queryParams.when_matched_update_all = 'true';
if (typeof args.whenMatchedUpdateAll === 'string') {
queryParams.when_matched_update_all_filt = args.whenMatchedUpdateAll;
}
}

@@ -200,0 +203,0 @@ else {

@@ -243,2 +243,3 @@ "use strict";

assert.equal(await table.countRows(), 10);
assert.equal(await table.countRows('vector IS NULL'), 0);
assert.deepEqual(await con.tableNames(), ['vectors']);

@@ -304,2 +305,3 @@ });

assert.equal(await table.countRows(), total);
assert.equal(await table.countRows('id < 5'), 5);
assert.deepEqual(await con.tableNames(), ['f16']);

@@ -445,2 +447,3 @@ assert.deepEqual(await table.schema, schema);

const table = await con.createTable('my_table', data);
// insert if not exists
let newData = [{ id: 2, age: 2 }, { id: 3, age: 2 }];

@@ -451,5 +454,13 @@ await table.mergeInsert('id', newData, {

assert.equal(await table.countRows(), 3);
assert.equal((await table.filter('age = 2').execute()).length, 1);
newData = [{ id: 3, age: 3 }, { id: 4, age: 3 }];
assert.equal(await table.countRows('age = 2'), 1);
// conditional update
newData = [{ id: 2, age: 3 }, { id: 3, age: 3 }];
await table.mergeInsert('id', newData, {
whenMatchedUpdateAll: 'target.age = 1'
});
assert.equal(await table.countRows(), 3);
assert.equal(await table.countRows('age = 1'), 1);
assert.equal(await table.countRows('age = 3'), 1);
newData = [{ id: 3, age: 4 }, { id: 4, age: 4 }];
await table.mergeInsert('id', newData, {
whenNotMatchedInsertAll: true,

@@ -459,8 +470,8 @@ whenMatchedUpdateAll: true

assert.equal(await table.countRows(), 4);
assert.equal((await table.filter('age = 3').execute()).length, 2);
newData = [{ id: 5, age: 4 }];
assert.equal((await table.filter('age = 4').execute()).length, 2);
newData = [{ id: 5, age: 5 }];
await table.mergeInsert('id', newData, {
whenNotMatchedInsertAll: true,
whenMatchedUpdateAll: true,
whenNotMatchedBySourceDelete: 'age < 3'
whenNotMatchedBySourceDelete: 'age < 4'
});

@@ -467,0 +478,0 @@ assert.equal(await table.countRows(), 3);

{
"name": "vectordb",
"version": "0.4.8",
"version": "0.4.9",
"description": " Serverless, low-latency vector database for AI applications",

@@ -88,8 +88,8 @@ "main": "dist/index.js",

"optionalDependencies": {
"@lancedb/vectordb-darwin-arm64": "0.4.8",
"@lancedb/vectordb-darwin-x64": "0.4.8",
"@lancedb/vectordb-linux-arm64-gnu": "0.4.8",
"@lancedb/vectordb-linux-x64-gnu": "0.4.8",
"@lancedb/vectordb-win32-x64-msvc": "0.4.8"
"@lancedb/vectordb-darwin-arm64": "0.4.9",
"@lancedb/vectordb-darwin-x64": "0.4.9",
"@lancedb/vectordb-linux-arm64-gnu": "0.4.9",
"@lancedb/vectordb-linux-x64-gnu": "0.4.9",
"@lancedb/vectordb-win32-x64-msvc": "0.4.9"
}
}

@@ -375,3 +375,3 @@ // Copyright 2023 Lance Developers.

*/
countRows: () => Promise<number>
countRows: (filter?: string) => Promise<number>

@@ -529,4 +529,15 @@ /**

* but that behavior is subject to change.
*
* Optionally, a filter can be specified. This should be an SQL
* filter where fields with the prefix "target." refer to fields
* in the target table (old data) and fields with the prefix
* "source." refer to fields in the source table (new data). For
* example, the filter "target.lastUpdated < source.lastUpdated" will
* only update matched rows when the incoming `lastUpdated` value is
* newer.
*
* Rows that do not match the filter will not be updated. Rows that
* do not match the filter do become "not matched" rows.
*/
whenMatchedUpdateAll?: boolean
whenMatchedUpdateAll?: string | boolean
/**

@@ -845,4 +856,4 @@ * If true then rows that exist only in the source table (new data)

*/
async countRows (): Promise<number> {
return tableCountRows.call(this._tbl)
async countRows (filter?: string): Promise<number> {
return tableCountRows.call(this._tbl, filter)
}

@@ -891,3 +902,10 @@

async mergeInsert (on: string, data: Array<Record<string, unknown>> | ArrowTable, args: MergeInsertArgs): Promise<void> {
const whenMatchedUpdateAll = args.whenMatchedUpdateAll ?? false
let whenMatchedUpdateAll = false
let whenMatchedUpdateAllFilt = null
if (args.whenMatchedUpdateAll !== undefined && args.whenMatchedUpdateAll !== null) {
whenMatchedUpdateAll = true
if (args.whenMatchedUpdateAll !== true) {
whenMatchedUpdateAllFilt = args.whenMatchedUpdateAll
}
}
const whenNotMatchedInsertAll = args.whenNotMatchedInsertAll ?? false

@@ -916,2 +934,3 @@ let whenNotMatchedBySourceDelete = false

whenMatchedUpdateAll,
whenMatchedUpdateAllFilt,
whenNotMatchedInsertAll,

@@ -918,0 +937,0 @@ whenNotMatchedBySourceDelete,

@@ -289,4 +289,7 @@ // Copyright 2023 LanceDB Developers.

}
if (args.whenMatchedUpdateAll ?? false) {
if (args.whenMatchedUpdateAll !== false && args.whenMatchedUpdateAll !== null && args.whenMatchedUpdateAll !== undefined) {
queryParams.when_matched_update_all = 'true'
if (typeof args.whenMatchedUpdateAll === 'string') {
queryParams.when_matched_update_all_filt = args.whenMatchedUpdateAll
}
} else {

@@ -293,0 +296,0 @@ queryParams.when_matched_update_all = 'false'

@@ -297,2 +297,3 @@ // Copyright 2023 LanceDB Developers.

assert.equal(await table.countRows(), 10)
assert.equal(await table.countRows('vector IS NULL'), 0)
assert.deepEqual(await con.tableNames(), ['vectors'])

@@ -373,2 +374,3 @@ })

assert.equal(await table.countRows(), total)
assert.equal(await table.countRows('id < 5'), 5)
assert.deepEqual(await con.tableNames(), ['f16'])

@@ -543,2 +545,3 @@ assert.deepEqual(await table.schema, schema)

// insert if not exists
let newData = [{ id: 2, age: 2 }, { id: 3, age: 2 }]

@@ -549,6 +552,15 @@ await table.mergeInsert('id', newData, {

assert.equal(await table.countRows(), 3)
assert.equal((await table.filter('age = 2').execute()).length, 1)
assert.equal(await table.countRows('age = 2'), 1)
newData = [{ id: 3, age: 3 }, { id: 4, age: 3 }]
// conditional update
newData = [{ id: 2, age: 3 }, { id: 3, age: 3 }]
await table.mergeInsert('id', newData, {
whenMatchedUpdateAll: 'target.age = 1'
})
assert.equal(await table.countRows(), 3)
assert.equal(await table.countRows('age = 1'), 1)
assert.equal(await table.countRows('age = 3'), 1)
newData = [{ id: 3, age: 4 }, { id: 4, age: 4 }]
await table.mergeInsert('id', newData, {
whenNotMatchedInsertAll: true,

@@ -558,9 +570,9 @@ whenMatchedUpdateAll: true

assert.equal(await table.countRows(), 4)
assert.equal((await table.filter('age = 3').execute()).length, 2)
assert.equal((await table.filter('age = 4').execute()).length, 2)
newData = [{ id: 5, age: 4 }]
newData = [{ id: 5, age: 5 }]
await table.mergeInsert('id', newData, {
whenNotMatchedInsertAll: true,
whenMatchedUpdateAll: true,
whenNotMatchedBySourceDelete: 'age < 3'
whenNotMatchedBySourceDelete: 'age < 4'
})

@@ -567,0 +579,0 @@ assert.equal(await table.countRows(), 3)

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc