NAMESPACE EXISTS
Checks whether a namespace exists.
Syntax
Section titled “Syntax”NAMESPACE EXISTS <namespace>Parameters
Section titled “Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
namespace | string | Yes | Dot-separated hierarchical path for the namespace (e.g. production.). |
Return Value
Section titled “Return Value”Boolean: true if the namespace exists, false if it does not.
RESP2 has no boolean type. On a RESP2 connection you get the integer 1 for true and 0 for false. See
Protocol Versions.
Behavior
Section titled “Behavior”The command checks the FoundationDB directory layer for the given namespace path. It uses an isolated one-off transaction.
If the directory entry exists but the namespace is marked for removal (NAMESPACE REMOVE), the command raises a
NAMESPACEBEINGREMOVED error rather than returning true. A namespace pending removal is not considered to exist.
The __internal__ reserved name is rejected at parse time.
Errors
Section titled “Errors”Argument errors:
| Error Code | Error message | Cause |
|---|---|---|
ERR | Namespace '<path>' is reserved for internal use | The namespace path contains the reserved __internal__ name. |
Namespace errors:
| Error Code | Error message | Cause |
|---|---|---|
NAMESPACEBEINGREMOVED | Namespace '<path>' is being removed | - |
Examples
Section titled “Examples”Namespace exists:
> NAMESPACE CREATE production.usersOK
> NAMESPACE EXISTS production.users(true)Namespace does not exist:
> NAMESPACE EXISTS production.orders(false)Reserved name:
> NAMESPACE EXISTS name.__internal__(error) ERR Namespace 'name.__internal__' is reserved for internal useNamespace being removed:
> NAMESPACE CREATE staging.ordersOK
> NAMESPACE REMOVE staging.ordersOK
> NAMESPACE EXISTS staging.orders(error) NAMESPACEBEINGREMOVED Namespace 'staging.orders' is being removed