Documentation ¶
Overview ¶
The JX9 Package represents a JX9 script code with the ability to compile and execute the code. In addtion there are code snippets to allow quick code creation for popular code snippets like Creating new collection(database) ,storing JSON/JSON list in a collection , removing JSON , removing collections...
Index ¶
- type JX9_script
- func (script *JX9_script) Compile(database ugo.Database) (string, ugo.VM, error)
- func (script JX9_script) CompileAndExecute(database ugo.Database) (string, string, ugo.VM, error)
- func (script *JX9_script) CreateOpenDataBase(database_name, pointer_name string)
- func (script *JX9_script) DeleteRecord(database_name string, record_id int64, result_variable string)
- func (script *JX9_script) DropCollection(database_name, variable_name string)
- func (script *JX9_script) FetchJsonByID(database_name string, record_id int64, variable_name string)
- func (script *JX9_script) FetchJsonList(database_name, variable_name, search_path string)
- func (script *JX9_script) GetAllFromDatatBase(database_name, variable_name string)
- func (script *JX9_script) GetDatabaseCopyRight(variable_name string)
- func (script *JX9_script) GetDatabaseSig(variable_name string)
- func (script *JX9_script) GetDatabaseTotalNumberOfRecords(databse_name, variable_name string)
- func (script *JX9_script) GetDatabaseVersion(variable_name string)
- func (script *JX9_script) GetScript() string
- func (script *JX9_script) InitScript()
- func (script *JX9_script) StoreJson(database_name, json_code, variable_name string)
- func (script *JX9_script) UpdateRecord(database_name string, record_id int64, new_json, variable_name string)
- func (script *JX9_script) UpdateScript(update_code string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type JX9_script ¶
type JX9_script struct {
// contains filtered or unexported fields
}
The JX9 script struct
func (*JX9_script) Compile ¶
Complie the jx9 script code to bytecompile code which lkate could be executed
databse:The databse struct which this code will compile aginst
The fuction will return the following
1.error:If compilation error occured it will be returned the error string please check , unqlitego.errString. If compilation suceeded than nil is returned. 2.string:If a compilation failed the error log will be returned, if compilation suceeded this should be ingnored 3.unqlitego.VM:The VM on which this code was compiled at (if compilation suceeded)
func (JX9_script) CompileAndExecute ¶
Complie the JX9 script code and execute it
databse:The databse struct which this code will compile aginst
The function will return the following
1,error:if error occured during coplialtion of the script return the error code 2.string:if error occured during copliation , return the error message 3.string:if copliation ended successfully the output of the script is returned 4.unqlitego.VM:The instance of the vm used to execute the script is returned
func (*JX9_script) CreateOpenDataBase ¶
func (script *JX9_script) CreateOpenDataBase(database_name, pointer_name string)
Add a code snippet create a database (collection), if the databse does not exists it will be automaticlly created database_name:The name of the databse (collection) to create pointer_name:The name of the JX9 variable which will hold the databse creation result
func (*JX9_script) DeleteRecord ¶
func (script *JX9_script) DeleteRecord(database_name string, record_id int64, result_variable string)
Add a code snipped to a JX9 script which removes a record by specifying it's record id database_name:The name of the database to drop the record from record_id:The id of the record to be removed result_variable:The name of the variable which will hold the results of the JX9 db_drop_record function can be true or false depending on if the record could be removed.
func (*JX9_script) DropCollection ¶
func (script *JX9_script) DropCollection(database_name, variable_name string)
Add a code snippet to a JX9 script which drops an entire databse (collection). database_name:The of databse to remove. variable_name:The name of the variable which will hold the result of JX9 db_drop_collection function The value returned can be true or false depending on the fact if the database could be removed.
func (*JX9_script) FetchJsonByID ¶
func (script *JX9_script) FetchJsonByID(database_name string, record_id int64, variable_name string)
Add Code snippet to the JX9 script which will search for specific JSON record with a specific id database_name:The name of the databse to grep the record from record_id:the record id (recod ids are generated automaticlly when adding a new record). variable_name:The return result of the db_fetch_by_id JX9 function
Ex: Assumiing that our databse have the following records stored 1. {"x":1,"y":{"a":,2},"__id":1} 2. {"x":1,"y":{"a":,3},"__id":2} 3. {"x":1,"y":{"a":,4},"__id":3} record_id=2 ,will result with, the following JSON {"x":1,"y":{"a":,3},"__id":2}
func (*JX9_script) FetchJsonList ¶
func (script *JX9_script) FetchJsonList(database_name, variable_name, search_path string)
Add Code snippet to the JX9 script which will search for specific JSON records according to a json path database_name:The name of the databse to greb all the record from variable_name:The name of the variable which will hold the result of the db_fetch_all function result. search_path:The JX9 json path format to be used for grabbing records:
Ex: Assumiing that our databse have the following records stored 1. {"x":1,"y":{"a":,2}} 2. {"x":1,"y":{"a":,3}} 3. {"x":1,"y":{"a":,4}} search_path="y.a>2" will return [{"x":1,"y":{"a":,3}},{"x":1,"y":{"a":,4}}]
func (*JX9_script) GetAllFromDatatBase ¶
func (script *JX9_script) GetAllFromDatatBase(database_name, variable_name string)
Add code snippet to the JX9 script which get all avaliable records from the databse. database_name:The name of the databse to greb all the record from variable_name:The name of the variable which will hold the result of the db_fetch_all function result.
func (*JX9_script) GetDatabaseCopyRight ¶
func (script *JX9_script) GetDatabaseCopyRight(variable_name string)
Add a JX9 code snippet which returnes a string representing the unqlite databse copyrights variable_name:The name of the variable which will hold the database copyrights string
func (*JX9_script) GetDatabaseSig ¶
func (script *JX9_script) GetDatabaseSig(variable_name string)
Add a JX9 code snippet which returnes a string representing the unqlite databse signature variable_name:The name of the variable which will hold the database signature string
func (*JX9_script) GetDatabaseTotalNumberOfRecords ¶
func (script *JX9_script) GetDatabaseTotalNumberOfRecords(databse_name, variable_name string)
Add a JX9 code snipped which returnes the database (collection) total number of records. database_name:The database name to count the number of records. variable_name:The name of the variable to hold the total number of databse records.
func (*JX9_script) GetDatabaseVersion ¶
func (script *JX9_script) GetDatabaseVersion(variable_name string)
Add a JX9 code snippet which returnes a string representing the unqlite databse version variable_name:The name of the variable which will hold the database version string
func (*JX9_script) InitScript ¶
func (script *JX9_script) InitScript()
Initialize the script (flush it to an empty string)
func (*JX9_script) StoreJson ¶
func (script *JX9_script) StoreJson(database_name, json_code, variable_name string)
This will add a JX9 snippet script to the current script which stores a JSON/JSON list to a database. database_name:The name of the database. json_code:The JSON/JSON list to be added to the databse. variable_name:The name of the variable which will hold the result of the db_store function result.
true: in case that adding a record ended successfully. false: in case that adding a record failed.
func (*JX9_script) UpdateRecord ¶
func (script *JX9_script) UpdateRecord(database_name string, record_id int64, new_json, variable_name string)
Add a code snippet to update a record , but basiclly it is removing records and adding a new one in-stand of it. database_name:The name of the databse to update the record at. record_id:The id of the JSON record to update. new_json:The new JSON to replace the JSON record to be removed. variable_name:The name of the variable which will hold the new record id, if replacemant was not possiable that it's value will be -1.
func (*JX9_script) UpdateScript ¶
func (script *JX9_script) UpdateScript(update_code string)
Append new code to the current script