GETTING STARTED

An entity–relationship model (or ER model) describes interrelated things of interest in a specific domain of knowledge. A basic ER model is composed of entity types (which classify the things of interest) and specifies relationships that can exist between entities (instances of those entity types).
The Javascript Entity Data Model (jedm) is an extended version of the Entity-Relationship model which provides javascripts models to specifies the conceptual model of the data using javascript.

Wahid Technology created a node module known as jsentitydatamodal. Use the the following steps to implement jsentitydatamodal JavaScript Data Entity Modal (JDEM)

1. Install following packages

a.  npm install jsentitydatamodal –dev—save

b.  npm install sequelize

c.  npm install body-parser dotenv express --save-dev

2. run node project

3. browse to localhost:xxxx/jedm where xxxx is the port number

4. following page will be open

5. Click the Create and fill the information

a.  Entity Modal Name

b.  Select database

i.  MSSQL

ii.  MYSQL

iii.  SQLite

c.  Select authentication (If MSSQL Selected)

i.  SQL Server Authentication

ii.  Windows Authentication

d.  Database server

e.  Database user name

f.  Database Password

g.  g. Database Name

6. Click on submit following page will be open

7. Select tables that you want to include in the entity modal (by default all tables are selected)

8. Select views if any (by default no view is selected)

9. Select stored procedures if any (by default no stored procedure is selected)

10. Select function if any (by default no function is selected)

11. Select function if any (by default no function is selected)

12. Add the following two references to your HTML

                            <script src="/js/jedmCommon.js"></script>
<script src="/js/jedmCommon.js"></script>

13. Use the following function to communicate with the database

xxxx.Select(objSql)

where xxxx is the name of entity modal (without spaces)

Required Parameter

objSQL object which contains SQL information see examples bellow

Example-1

/**
*
* SELECT * FROM Customers
*
*/

let sqlInfo = {
EntityName:'Customers'
};

xxxx.Select(sqlInfo).then(function(result){
//Data available here in result object
}).catch(function(error){
//Show error here
});

Example-2

/**
*
* SELECT * FROM Customers
* WHERE CustomerID = 'WT123'
*
*/

let sqlInfo = {
EntityName:'Customers',
WhereClause:"CustomerID='WT123'"
};

xxxx.Select(sqlInfo).then(function(result){
//Data available here in result object
}).catch(function(error){
//Show error here
});

Example-3

/**
*
* SELECT CustomerID, CompanyName, ContactName
FROM Customers
* WHERE CustomerID = 'WT123'
*
*/

let sqlInfo = {
EntityName:'Customers',
Columns:'CustomerID, CompanyName, ContactName',
WhereClause:"CustomerID='WT123'"
};

xxxx.Select(sqlInfo).then(function(result){
//Data available here in result object
}).catch(function(error){
//Show error here
});

xxxx.Insert(objSql)

where xxxx is the name of entity modal (without spaces)

Required Parameter

objSQL object which contains SQL information see examples bellow

Example

let customer = await xxxx.Customers;
customer.CustomerID='WT123';
customer.CompanyName='Wahid Technology';

let sqlInfo = {
EntityName:'Customers',
Data:customer
};

xxxx.Insert(sqlInfo).then(function(result){
//Data available here in result object
}).catch(function(error){
//Show error here
});

xxxx.Delete(objSql)

where xxxx is the name of entity modal (without spaces)

Required Parameter

objSQL object which contains SQL information see examples bellow

Example

let sqlInfo = {
EntityName:'Customers',
WhereClause:"CustomerID='WT123'"
};

xxxx.Deletet(sqlInfo).then(function(result){
//Data available here in result object
}).catch(function(error){
//Show error here
});

xxxx.Update(objSql)

where xxxx is the name of entity modal (without spaces)

Required Parameter

objSQL object which contains SQL information see examples bellow

Example

let sqlInfo = {
EntityName:'Customers',
Columns:"CustomerID='Wahid'"
WhereClause:"CustomerID='WT123'"
};

xxxx.Update(sqlInfo).then(function(result){
//Data available here in result object
}).catch(function(error){
//Show error here
});

xxxx.ExecQuery(objSql)

where xxxx is the name of entity modal (without spaces)

Required Parameter

objSQL object which contains SQL information see examples bellow

Example

let sqlInfo = {
SQLQuery:"SELECT *
FROM Customers
WHERE City='London'
Order By CompanyName"
};

xxxx.ExecQuery(sqlInfo).then(function(result){
//Data available here in result object
}).catch(function(error){
//Show error here
});

xxxx.ExecStoredProcedure(objSql)

where xxxx is the name of entity modal (without spaces)

Required Parameter

objSQL object which contains SQL information see examples bellow

Example

let sqlInfo = {
Name:'CustOrderHist',
Parameters:"@CustomerID='ALFKI'" // add multiple parameter with comma seprater
};

xxxx.ExecStoredProcedure(sqlInfo).then(function(result){
//Data available here in result object
}).catch(function(error){
//Show error here
});