Redmix
A fun and friendly Appcelerator Cloud MBaaS command line.
Installation
$ [sudo] npm install redmix -g
Usage
Get all the available commands and options:
$ redmix help 🍷 Redmix « A fun and friendly Appcelerator Cloud MBaaS command line » v0.0.1Copyright 2015 by Jeff Haynie. All Rights Reserved. Usage: redmix cmd [options] Commands: create [options] create a data object connect <appid> [options] connect to a cloud app query <object> <query> [options] query objects sql <query> [options] query objects using SQL disconnect [options] disconect from a cloud app help [cmd] display help
Connect to ACS
$ redmix connect ? API Key: 098s09df8a90s8df09a8s9f8d0a98sdf908asdf? Username/Email: myusername? Password: ********************************Application connected. You can now make requests
You can also connect to multiple ACS apps at the same time. To use multiple connections, use the --alias
flag when you connect.
The alias should be set to a name that you will later reference on other calls to Redmix using the same flag.
For example, let's say you have 2 different apps:
$ redmix connect 12345 myusername mypass --alias acs1$ redmix connect 56789 myotheruser mypass --alias acs2 --default
You can use the --default
option to indicate the if no default is specified on the command line, to use that specific connection.
Now you can switch easily between different connections:
$ redmix sql "select * from files" --alias acs1$ redmix sql "select * from files" --alias acs2
Query an Object
Query files which have a name starting with appc and return the oldest one:
$ redmix query Files "name like appc" --order created_at --limit 1
Query files with a more complex example:
$ redmix query Files "name!=foo" "module_version not in 0.1.0" "module_version_sortable > 100" --order=-module_version_sortable --sel module_version,name,module_version_sortable --limit 2 --eval "this.map(function(e){return e.custom_fields.module_version;})"
In the above example, we would see something like:
[
"1.0.23",
"1.0.18"
]
Query using SQL
Limited support for basic SQL is supported. Currently, only for SELECT statements.
$ redmix sql "select name, url from Files where name like 'appc' order by url DESC LIMIT 1"
You can delete:
$ redmix sql "delete from foo where name = 'hello'"
You can do limited sql expressions:
$ redmix sql "select count(*) from foo"
You can do some advanced things like group by and order by:
$ redmix sql "select module_name, sum(module_filesize) as size from Files where module_filesize > 0 group by module_name order by size desc LIMIT 1000"
Create an Object
Create a File object from the package.json and add a custom field (filetype):
$ redmix create Files "name=package.json,file=./package.json,filetype=json"
Disconnect
Disconnect from ACS:
$ redmix disconnect
Output Formats
Redmix supports outputting in several different formats by specifying the --output
options.
text
- default output, colorized (if enabled) textjson
- JSONcsv
- Comma separatedtsv
- Tab separatedcolumns
- Columns
For example, an advanced query with column output:
$ redmix sql "select module_name, sum(module_filesize) as size from Files where module_filesize > 0 group by module_name order by size desc LIMIT 1000" -o columns --no-bannerSIZE MODULE_NAME51053123 appcelerator542404 appc.salesforce94613 appc.dashboard25852 appc.mongo10413 appc.mysql9693 appc.stripe9634 appc.mssql9515 appc.swagger7781 com.model7456 appc.composite6589 appc.azure6090 appc.acs
Using as an API
You can use Redmix as a node library as well.
For example, to execute a query you can do something like this:
var redmix = ;redmix;
Troubleshooting
If you run into an issue, please re-try your request with the --debug
flag (on command line). This should print out a little more debugging for things like parsing the SQL, building the ACS request, etc. If you do run into an issue, please open a GitHub issues or even better, submit a pull request.
TODO
See the complete issues list in GitHub issues.
License
Licensed under the Apache Public License, version 2. Copyright (c) 2015 by Jeff Haynie. All Rights Reserved.