Skip to content

@lancedb/lancedbDocs


@lancedb/lancedb / connectNamespace

Function: connectNamespace()

connectNamespace(implName, config, options)

function connectNamespace(
   implName,
   config,
   options?): Promise<Connection>

Connect to a LanceDB database through a namespace.

Unlike connect, which routes by URI scheme (local path vs. db:// cloud), connectNamespace always returns a namespace-backed connection. The implName selects the namespace implementation:

  • "dir" — directory namespace, configured with DirNamespaceConfig.
  • "rest" — remote REST catalog, configured with RestNamespaceConfig.
  • Any other string — full module path for a custom implementation, configured with a free-form string-keyed properties map.

Parameters

Returns

Promise<Connection>

Examples

const db = await connectNamespace("dir", { root: "/path/to/db" });
await db.createTable("users", [{ id: 1 }]);
const db = await connectNamespace("rest", {
  uri: "https://catalog.example.com",
  headers: { "x-api-key": process.env.CATALOG_KEY ?? "" },
});
const db = await connectNamespace("my.custom.Namespace", {
  endpoint: "...",
});

connectNamespace(implName, config, options)

function connectNamespace(
   implName,
   config,
   options?): Promise<Connection>

Connect through the built-in REST namespace.

Configured with RestNamespaceConfig. See the function-level documentation above for the full surface, examples, and how this relates to connect.

Parameters

Returns

Promise<Connection>

Example

const db = await connectNamespace("rest", {
  uri: "https://catalog.example.com",
  headers: { "x-api-key": process.env.CATALOG_KEY ?? "" },
});

connectNamespace(implName, properties, options)

function connectNamespace(
   implName,
   properties,
   options?): Promise<Connection>

Connect through a custom namespace implementation by full module path, configured with a free-form string-keyed properties map. Use the typed overloads above for the built-in "dir" and "rest" impls.

See the function-level documentation above for examples and how this relates to connect.

Parameters

Returns

Promise<Connection>

Example

const db = await connectNamespace("my.custom.Namespace", {
  endpoint: "...",
});