Skip to content

Commit

Permalink
readme
Browse files Browse the repository at this point in the history
  • Loading branch information
cristo-rabani committed Aug 19, 2015
1 parent 766df04 commit 6e2a49d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,26 @@ If you want create a local collection please pass in options property: `connecti
console.log(docInstance.getTitleUppercase());
```

- `create` Creates new instance of document for current collection. Create method accepts arguments rawDoc, options.

```js
// empty not saved instance of doc
var docInstance = collection.create();
// warning: some of methods cannot work properly without some fields
console.log(docInstance.getCollectionName());
```
You can pass a raw object of document and save it after or save it in the moment of creation by options parameter.

```js
// not saved instance of doc
var docInstance = collection.create({title: 'abc'});
// manual save
docInstance.save();
// saving it in the moment of creation
var docInstance2 = collection.create({title: 'abcd'}, true);
// saving it in the moment of creation with different schema
var docInstance3 = collection.create({title: 'abcde'}, {save: true, useSchema: 'schemaName'});
```
- `methods`
Remote methods on collection that can be invoked over the network by clients from collection instance.
From UniCollection you can define and call remote methods (just like Meteor.methods and Meteor.call).
Expand Down
4 changes: 2 additions & 2 deletions lib/UniCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -470,8 +470,8 @@ UniCollection.prototype.getCollectionName = function () {
};

/**
* Creates instance of collection document
* @param {Object=} rawDoc object with field value pairs or undefined
* Creates new instance of document for current collection
* @param {Object=} rawDoc object with fieldName value pairs or undefined
* @param {Object|Boolean=} options if is true or properly save is set as true
* then document will be saved after creation. The other options are passed to doc.save method.
* @param {Boolean} options.save Document should be saved after creation.
Expand Down

0 comments on commit 6e2a49d

Please sign in to comment.