Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README.md , Wrap comments #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 22 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ use Mocker.mock to create some data for test :
var fruitsDataSource = Mocker.mock({
template: { say: 'hello' },
amount: 100,
idAttribute: 'id', // or json full format: { key: 'id', prefix: 'fruit_' }

// or json full format: { key: 'id', prefix: 'fruit_' }
idAttribute: 'id',

randomAttributes: [{
key: 'type',
values: [ 'apple', 'banana', 'orange', 'grapes' ]
Expand All @@ -20,10 +23,14 @@ use Mocker.mock to create some data for test :
key: 'time',
values: { min: 1325347200000, max: 1356883200000 }
}],
onCreate: function( item ) { // item on create callback

// item on create callback
onCreate: function( item ) {
item.say = 'hi';
},
delay: 1000 // simulate request & response delay

// simulate request & response delay
delay: 1000
});
```

Expand All @@ -38,8 +45,13 @@ the Mocking dataSource you create can do something query like :
```javascript
fruitsDataSource({
params: {
query: 'type gte {a}, type lte {z}, time gt {0}', // or json format: [ { key: 'type', operator: 'like', value: 'apple' } ]
sort: 'type asc, time desc', // or json format: [ { key: 'time', order: 'desc' } ]

// or json format: [ { key: 'type', operator: 'like', value: 'apple' } ]
query: 'type gte {a}, type lte {z}, time gt {0}',

// or json format: [ { key: 'time', order: 'desc' } ]
sort: 'type asc, time desc',

skip: 0,
limit: 100,
count: true
Expand All @@ -60,7 +72,9 @@ asol save :
```javascript
fruitsDataSource({
params: {
save: { // or string format: "{ 'type': 'orange', 'taste': 'bad' }"

// or string format: "{ 'type': 'orange', 'taste': 'bad' }"
save: {
type: 'apple',
taste: 'awesome',
time: new Date().getTime()
Expand All @@ -77,7 +91,8 @@ remove :
```javascript
fruitsDataSource({
params: {
remove: 'taste eq {shit smells}' // or json format: [ { key: 'taste', operator: 'nq', value: 'awesome' } ]
// or json format: [ { key: 'taste', operator: 'nq', value: 'awesome' } ]
remove: 'taste eq {shit smells}'
},
success: function( count ) {
console.log( 'data count of remove: ' + count );
Expand Down