Fixed some broken links and added ACL example in createModel()

This commit is contained in:
Rand McKinney 2013-12-16 13:54:17 -08:00
parent 9841a86a46
commit d075821c32
1 changed files with 19 additions and 1 deletions

View File

@ -1,6 +1,6 @@
## Data Source object
A Loopback `DataSource` provides [Models](#model) with the ability to manipulate data. Attaching a `DataSource` to a `Model` adds [instance methods](#instance-methods) and [static methods](#static-methods) to the `Model`. The added methods may be [remote methods](#remote-methods).
LoopBack models can manipulate data via the DataSource object. Attaching a `DataSource` to a `Model` adds instance methods and static methods to the `Model`; some of the added methods may be remote methods.
Define a data source for persisting models.
@ -24,6 +24,24 @@ Define a model and attach it to a `DataSource`.
var Color = oracle.createModel('color', {name: String});
```
You can define an ACL when you create a new data source with the `DataSource.create()` method. For example:
```js
var Customer = ds.createModel('Customer', {
name: {
type: String,
acls: [
{principalType: ACL.USER, principalId: 'u001', accessType: ACL.WRITE, permission: ACL.DENY},
{principalType: ACL.USER, principalId: 'u001', accessType: ACL.ALL, permission: ACL.ALLOW}
]
}
}, {
acls: [
{principalType: ACL.USER, principalId: 'u001', accessType: ACL.ALL, permission: ACL.ALLOW}
]
});
```
### dataSource.discoverModelDefinitions([username], fn)
Discover a set of model definitions (table or collection names) based on tables or collections in a data source.