API: dao
Source:
mongodb/dao.ts
Reads a single entity by id, parsed into JSON object. If requested as expanded the returned entity will comprise associated (dependent) entities too. Expand can be a string tha tis a valid association name defined in this dao orm or an array of such names.
Usage
javascript
import { dao } from "sdk/mongodb";
import { response } from "sdk/http";
//create a DAO from configuration
let customers = dao.create({
table: "CUSTOMERS",
properties: [{
name: "id",
column: "ID",
type: "BIGINT",
id: true
}, {
name: "orgName",
column: "ORG_NAME",
type: "VARCHAR",
required: true
}, {
name: "employeesNumber",
column: "ORG_EMP_NUM",
type: "INTEGER",
required: true
}, {
name: "orgDescription",
column: "ORG_DESCR",
type: "VARCHAR",
required: false
}]
});
//Create a new customer entity
let customerId = customers.insert({
orgName: "ACME",
employeesNumber: 1000
});
response.println("Id: " + customerId);
//List all customer entities
let customersList = customers.list();
//Get a particular customer entity by its id
let customer = customers.find(customerId);
//Update a customer entity property
customer.orgDescription = "ACME is a company";
customers.update(customer);
//Delete a customer entity
customers.remove(customerId);Classes
DAO
Methods
notify
notify (event, ...a):void
createNoSQLEntity
createNoSQLEntity (entity):any
validateEntity
validateEntity (entity, skip):void
insert
insert (_entity)void
update
update (entity)void
remove
remove (id)void
expand
expand (expansionPath, context)void
find
find (id, expand, select)voidReads a single entity by id, parsed into JSON object.
If requested as expanded the returned entity will comprise associated (dependent) entities too. Expand can be a string tha tis a valid association name defined in this dao orm or
an array of such names.
count
count ():number
list
list (settings)voidlist parameters:
- $expand
- $filter
- $select
- $sort
- $order
- $limit
- $offset
existsTable
existsTable ():boolean
createTable
createTable ():void
dropTable
dropTable ():DAO