Mosql.Export (mosql v0.1.0)
Represents the export definition and other configurations of the export
ns
namespace has to be unique across the system.
exclusions
optional list of collections to exclude from the export
exclusives
optional list of only collections to export. if only list is present exclusion
list is ignored.
source_db_opts
and destination_db_opts
contains the source and destination
database details. It's a keyword list with following optional keys:
`db_name`
`connection_url`
Link to this section Summary
Functions
Add list of collections to exclude from the export. Schema definition generation is also skipped for these excluded collections
Add a list of only collections to export. If this is present all the other collections are excluded by default even if exclusion list is present
Delete the export for the given namespace and type
Retruns the name of the destination database TODO: fetch the db details from export.destination_db_opts
Fetch the saved export for the given namespace and type.
Generate a default schema mapping for a collection based on the given collection name
Generate schema mappings for the given export based on the collection data fields. Default alphabetical sorting is applied to the schema based on the collection names. Collection fields will follow a sorting order of the primary key(s) such as id and then the order based on the field types
Creates a new export definition based on the given namespace and type namespace should be unique among all the exports saved in the system
Populate the schema store (Mosql.Store
) for the data export process
Save the export to the persistent store
Set up the Mnesia Database for MoSQL
on disk
This creates the necessary Schema, Database and
Tables for MoSQL export data on disk for the specified
erlang nodes so export definitions are persisted across
application restarts. Note that this call will stop
the :mnesia
application. If no argument is provided,
the database is created for the current node.
Saves the raw JSON for the export
Update the saved export for the given namespace and type
Link to this section Types
Link to this section Functions
add_exclusions(namespace, type, exclusions)
Add list of collections to exclude from the export. Schema definition generation is also skipped for these excluded collections
add_exclusives(namespace, type, exclusives)
Add a list of only collections to export. If this is present all the other collections are excluded by default even if exclusion list is present
delete(namespace, type)
Delete the export for the given namespace and type
destination_db_name(_)
Retruns the name of the destination database TODO: fetch the db details from export.destination_db_opts
fetch(namespace, type)
@spec fetch(String.t(), String.t()) :: {:ok, %Mosql.Export{ destination_db_opts: term(), exclusions: term(), exclusives: term(), ns: term(), schemas: term(), source_db_opts: term(), type: term() }} | {:error, :not_found}
Fetch the saved export for the given namespace and type.
fetch_all()
generate_schema_map(namespace, collection)
Generate a default schema mapping for a collection based on the given collection name
generate_schema_mappings(export)
Generate schema mappings for the given export based on the collection data fields. Default alphabetical sorting is applied to the schema based on the collection names. Collection fields will follow a sorting order of the primary key(s) such as id and then the order based on the field types
new(namespace, type, options \\ [])
Creates a new export definition based on the given namespace and type namespace should be unique among all the exports saved in the system
populate_schema_store(export)
Populate the schema store (Mosql.Store
) for the data export process
save(ex)
Save the export to the persistent store
setup!(nodes \\ [node()])
@spec setup!(nodes :: [node()]) :: :ok
Set up the Mnesia Database for MoSQL
on disk
This creates the necessary Schema, Database and
Tables for MoSQL export data on disk for the specified
erlang nodes so export definitions are persisted across
application restarts. Note that this call will stop
the :mnesia
application. If no argument is provided,
the database is created for the current node.
Setup has to be performed from the console
iex> Mosql.Export.setup!()
:ok
NOTE: This needs to be done only once and not every time the application starts. It also makes sense to create a helper function or mix task to do this
to_json(export, export_path)
Saves the raw JSON for the export
update(namespace, type, export)
Update the saved export for the given namespace and type