ndb Functions Reference
The function API only available if you’ve imported the NimbusDBFnAPI script asset. The ndb functions are designed for users who prefer a functional programming style over the object-oriented (OOP) approach provided by NimbusDB core classes.
Using the ndb API
Section titled “Using the ndb API”Before you can use the ndb functions, ensure that you’ve included the NimbusDBFnAPI script in your project.
To use the ndb functions, you can call them directly in your code, with the first parameter being the class instance they operate on.
// (1) creating a new class instancevar my_model = new NimbusDBModel(id, "my_model"); // OOP stylevar my_model = ndb_create_model(id, "my_model"); // functional style
// (2) calling a method on the class instancemy_model.insert({ id: 1, name: "Apple", price: 5 }); // OOP stylendb_insert(my_model, { id: 1, name: "Apple", price: 5 }); // functional style
// (3) getting a return value from the functionvar apple = my_model.get_by_primary(1); // OOP stylevar apple = ndb_get_by_primary(my_model, 1); // functional stylendb_computed()
Section titled “ndb_computed()”See Model.computed() for details.
ndb_create_alias()
Section titled “ndb_create_alias()”See Model.expose() for details.
ndb_cross_join()
Section titled “ndb_cross_join()”See Model.cross_join() for details.
ndb_delete_alias()
Section titled “ndb_delete_alias()”See Model.unexpose() for details.
ndb_create_model()
Section titled “ndb_create_model()”See Model constructor for details. Substitute new NimbusDBModel for ndb_create_model.
ndb_define_relation()
Section titled “ndb_define_relation()”See Model.define_relation() for details.
ndb_derived()
Section titled “ndb_derived()”See Model.derived() for details.
ndb_destroy_model()
Section titled “ndb_destroy_model()”Destroys a model instance.
Signature
Section titled “Signature”function ndb_destroy_model( _model: NimbusDBModel): void;Parameters
Section titled “Parameters”_model
Section titled “_model”- Type:
NimbusDBModel - The model instance to operate on.
Example
Section titled “Example”var model = ndb_create_model("items", { id: { type: NIMBUSDB_DATA_TYPE.INTEGER, const: NIMBUSDB_CONSTRAINT.PRIMARY_KEY }, name: NIMBUSDB_DATA_TYPE.STRING, price: { type: NIMBUSDB_DATA_TYPE.NUMBER, validator: function(data, value) { return value >= 0; }, default_value: 0 }, is_locked: { type: NIMBUSDB_DATA_TYPE.BOOLEAN, const: NIMBUSDB_CONSTRAINT.OPTIONAL, default_value: false }});
ndb_destroy_model(model);ndb_drop_relation()
Section titled “ndb_drop_relation()”See Model.drop_relation() for details.
ndb_export_csv()
Section titled “ndb_export_csv()”See Model.export_csv() for details.
ndb_export_json()
Section titled “ndb_export_json()”See Model.export_json() for details.
ndb_export_ndbin()
Section titled “ndb_export_ndbin()”See Model.export_ndbin() for details.
ndb_find()
Section titled “ndb_find()”See Model.find() for details.
ndb_full_join()
Section titled “ndb_full_join()”See Model.full_join() for details.
ndb_get_alias()
Section titled “ndb_get_alias()”See Model.get_alias() for details.
ndb_get_by_*()
Section titled “ndb_get_by_*()”See:
- Model.get_by_index() for
ndb_get_by_index(). - Model.get_by_primary() for
ndb_get_by_primary(). - Model.get_by_value() for
ndb_get_by_value(). - Model.get_by_function() for
ndb_get_by_function().
ndb_get_by_*_linked()
Section titled “ndb_get_by_*_linked()”See:
- Model.get_by_index_linked() for
ndb_get_by_index_linked(). - Model.get_by_primary_linked() for
ndb_get_by_primary_linked(). - Model.get_by_value_linked() for
ndb_get_by_value_linked(). - Model.get_by_function_linked() for
ndb_get_by_function_linked().
ndb_get_by_*_destruct()
Section titled “ndb_get_by_*_destruct()”See:
- Model.get_by_index_destruct() for
ndb_get_by_index_destruct(). - Model.get_by_primary_destruct() for
ndb_get_by_primary_destruct(). - Model.get_by_value_destruct() for
ndb_get_by_value_destruct(). - Model.get_by_function_destruct() for
ndb_get_by_function_destruct().
ndb_get_count()
Section titled “ndb_get_count()”See Model.get_count() for details.
ndb_get_relation()
Section titled “ndb_get_relation()”See Model.get_relation() for details.
ndb_import_csv()
Section titled “ndb_import_csv()”See Model.import_csv() for details.
ndb_import_json()
Section titled “ndb_import_json()”See Model.import_json() for details.
ndb_import_ndbin()
Section titled “ndb_import_ndbin()”See Model.import_ndbin() for details.
ndb_inner_join()
Section titled “ndb_inner_join()”See Model.inner_join() for details.
ndb_insert()
Section titled “ndb_insert()”See Model.insert() for details.
ndb_left_join()
Section titled “ndb_left_join()”See Model.left_join() for details.
ndb_migrate_data()
Section titled “ndb_migrate_data()”See Model.migrate() for details.
ndb_print()
Section titled “ndb_print()”See Model.print() for details.
ndb_remove_by_*()
Section titled “ndb_remove_by_*()”See:
- Model.remove_by_index() for
ndb_remove_by_index(). - Model.remove_by_primary() for
ndb_remove_by_primary(). - Model.remove_by_value() for
ndb_remove_by_value(). - Model.remove_by_function() for
ndb_remove_by_function().
ndb_right_join()
Section titled “ndb_right_join()”See Model.right_join() for details.
ndb_transaction()
Section titled “ndb_transaction()”See Model.transaction() for details.
ndb_update_by_*()
Section titled “ndb_update_by_*()”See:
- Model.update_by_index() for
ndb_update_by_index(). - Model.update_by_primary() for
ndb_update_by_primary(). - Model.update_by_value() for
ndb_update_by_value(). - Model.update_by_function() for
ndb_update_by_function().
ndb_upsert()
Section titled “ndb_upsert()”See Model.upsert() for details.
ndb_watch()
Section titled “ndb_watch()”See Model.watch() for details.
Catalog
Section titled “Catalog”ndb_backup_catalog()
Section titled “ndb_backup_catalog()”See Catalog.backup() for details.
ndb_catalog_add_model()
Section titled “ndb_catalog_add_model()”See Catalog.add_model() for details.
ndb_catalog_clear_model()
Section titled “ndb_catalog_clear_model()”See Catalog.clear() for details.
ndb_catalog_define_model()
Section titled “ndb_catalog_define_model()”See Catalog.define() for details.
ndb_catalog_define_relation()
Section titled “ndb_catalog_define_relation()”See Catalog.define_relation() for details.
ndb_catalog_define_mutual_relation()
Section titled “ndb_catalog_define_mutual_relation()”See Catalog.define_mutual_relation() for details.
ndb_catalog_drop_model()
Section titled “ndb_catalog_drop_model()”See Catalog.drop() for details.
ndb_catalog_drop_relation()
Section titled “ndb_catalog_drop_relation()”See Catalog.drop_relation() for details.
ndb_catalog_get_relation()
Section titled “ndb_catalog_get_relation()”See Catalog.get_relation() for details.
ndb_catalog_has_model()
Section titled “ndb_catalog_has_model()”See Catalog.has() for details.
ndb_catalog_list_models()
Section titled “ndb_catalog_list_models()”See Catalog.list() for details.
ndb_catalog_transaction()
Section titled “ndb_catalog_transaction()”See Catalog.transaction() for details.
ndb_catalog_use_model()
Section titled “ndb_catalog_use_model()”See Catalog.use() for details.
ndb_create_catalog()
Section titled “ndb_create_catalog()”See Catalog constructor for details. Substitute new NimbusDBCatalog for ndb_create_catalog.
ndb_destroy_catalog()
Section titled “ndb_destroy_catalog()”Destroys a catalog instance.
Signature
Section titled “Signature”function ndb_destroy_catalog( _catalog: NimbusDBCatalog): void;Parameters
Section titled “Parameters”_catalog
Section titled “_catalog”- Type:
NimbusDBCatalog - The catalog instance to operate on.
Example
Section titled “Example”var catalog = ndb_create_catalog("my_catalog");
ndb_destroy_catalog(catalog);ndb_restore_catalog()
Section titled “ndb_restore_catalog()”See Catalog.restore() for details.