SQLJSON
I. User Authentication and Authorization.
New registration will also create a new workgroup. By default you will have a "DIRECTOR" roles of the group.
You can add a new user to your workgroup, and customize the user roles of your workgroup. To manages Workgroup and Authoziation, you need to have a "ADMINISTRATOR" role, and by default you will have it on your new application.
1. Workgroup.
2. User Workgroups.
3. User Workgroup Roles.
4. Add new user to Workgroup.
a. Click Plus button.
II. Create New Backend Service.
Create Project.
III. Publish Project.
You can modify your project, tables, store procedures, roles. If you modify your project you need to redeploy your project.
1. On the top left menu button, Click "Create Subscription" on the menu.
2. Select your Project.
3. Select your hosting package options.
Modify and Redeploy Project.
V. Javascript Client SDK.
The Javascript Client SDK work with Event Driven Programming and fully asyncronous.
1. Initialize Connection.
Basic Initialization.
Put on head of index.html
<script type="text/javascript" src="https://[DOMAINNAME]/res/js/production/app.res.js.production.js"></script>
<script type="text/javascript" src="https://cdn.ardvro.com/ardvro/ardvro.js"></script>
<script type="text/javascript">
const WEBSOCKETURL = "ardvro.com";
const WEBBASEURL = "https://[DOMAINNAME]";
const CDNURL = "https://cdn.ardvro.com";
window.onload = function ()
{
Loader.Start(listeners);
};
(function ()
{
Loader.InitDependencies(WEBBASEURL, CDNURL, dependencies);
})();
</script>
Custom initialization.
You can create any custom initialization logic, but you need to call Loader.Start(...) first. You can also custommize the dependencies.
Example custom Initalization:
var Cms = (function ()
{
let cms = {};
let _profileController;
let _contentController;
let _profile = {};
function getProfile()
{
return _profile;
}
function setProfile(profile)
{
_profile = profile;
}
cms.GetProfile = function ()
{
return getProfile();
};
cms.InitMenu = function (websiteStartuper, usr)
{
_profileController = new ProfileController({
Connector: websiteStartuper.GetConnector(),
GetServerTime: websiteStartuper.GetServerTimeFunction(),
OnLoad: function (profileCtrl)
{
_contentController = new ContentController({
Connector: websiteStartuper.GetConnector(),
GetServerTime: websiteStartuper.GetServerTimeFunction(),
OnLoad: function (ctrl)
{
if (websiteStartuper.GetUser() != null && usr != null)
{
registerProfile(ctrl, profileCtrl, websiteStartuper.GetUser(), websiteStartuper.GetAppName(), websiteStartuper.GetServerTimeFunction(),
function (profileResult)
{
reinitMenuItems(ctrl, profileCtrl, websiteStartuper, profileResult);
setProfile(profileResult);
}
);
}
else
{
reinitMenuItems(ctrl, profileCtrl, websiteStartuper, {});
let chatContentField = Object.keys(websiteStartuper.GetWebsiteSetting()).find(x => x.includes(CONTENT_CHAT_ID));
if (chatContentField != null)
{
let chatContentId = websiteStartuper.GetWebsiteSetting()[chatContentField];
if (chatContentId != null && !isNaN(chatContentId))
{
let wigChat = new ChatWidget({
Id: "chatWidget",
Label: "Chat Widget",
cmsContentId: Number(chatContentId),
CdnUrl: websiteStartuper.GetCdnUrl(),
Theme: websiteStartuper.GetTheme(),
Connector: websiteStartuper.GetConnector(),
Authenticator: websiteStartuper.GetAuthenticator(),
GetServerTime: websiteStartuper.GetServerTimeFunction(),
AppName: websiteStartuper.GetAppName(),
NotificationListeners: websiteStartuper.GetNotificationListeners()
});
wigChat.Tonggle();
}
}
}
}
});
}
});
};
2. Initalized DB Context.
After Websocket connection establish, next it need to initialize the DBContext. The DBContext object will be retrived base on the Authorization configuration.
let dbcontext = new SqlJson({ Connector: cfg.Connector });
3. Get Data.
dbcontext.Customer.Where("Name like (?) and status in (?)", name, [1,2,3]).OrderBy("Name ASC").Limit(0, 10).PagingJsons("*").Send(function(results){ let list = JSON.parse(results); });
4. Upsert.
let data = {};
data.Id = 0;
data.Status = 1;
data.Updated = cfg.GetServerTime().Format('yyyy-MM-dd HH:mm:ss');
data.Updater = "";
data.VoteType = voteType;
data.Value = voteValue;
data.pfeProfileId = profileId;
data.cmsContentId = contentId;
dbcontext.cmsContentVote.Save(data).Send(function (result)
{
if (callback != null)
{
callback(result);
}
});
5. Delete.
dbcontext.cmsContentVote.Delete(data).Send(function (result)
{
if (callback != null)
{
callback(result);
}
});
6. Call Store Procedure.
dbcontext.sp_cmsContentTags.ProcedureJsons(pageIndex, rows, orderMode).Send(function (jsons)
{
if (callback != null)
{
let list = [];
if (jsons != null && jsons != "")
{
list = JSON.parse(jsons);
}
callback(list);
}
});
7. More example, visit: https://github.com/ardvro