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”Integer: 1 if the namespace exists, 0 if it does not.
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 1. A namespace pending removal is not considered to exist.
The __internal__ reserved name is rejected at parse time.
Errors
Section titled “Errors”| Error Code | Description |
|---|---|
NAMESPACEBEINGREMOVED | The namespace was previously removed via NAMESPACE REMOVE but has not yet been purged via NAMESPACE PURGE. |
ERR | The namespace path contains the reserved __internal__ leaf. |
Examples
Section titled “Examples”Namespace exists:
> NAMESPACE CREATE production.usersOK
> NAMESPACE EXISTS production.users(integer) 1Namespace does not exist:
> NAMESPACE EXISTS production.orders(integer) 0Reserved 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