meteor-sdk
Version:
The aim of this library is to simplify the process of working with meteor server over DDP protocol using external JS environments
1,517 lines (655 loc) • 30.7 kB
HTML
<html>
<head>
<meta charset="utf-8">
<title>SimpleDDP Docs</title>
<meta name="description" content="SimpleDDP Docs" />
<meta name="keywords" content="ddp, simpleddp, websocket, meteor" />
<meta name="keyword" content="ddp, simpleddp, websocket, meteor" />
<meta property="og:title" content="SimpleDDP Docs"/>
<meta property="og:type" content="website"/>
<meta property="og:image" content="https://github.com/Gregivy/simpleddp/raw/2.x.x/simpleddp.png"/>
<meta property="og:site_name" content="SimpleDDP Docs"/>
<meta property="og:url" content=""/>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="scripts/prettify/prettify.js"></script>
<script src="scripts/prettify/lang-css.js"></script>
<script src="scripts/jquery.min.js"></script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link href="https://fonts.googleapis.com/css?family=Libre+Franklin:400,700" rel="stylesheet">
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/bootstrap.min.css">
<link type="text/css" rel="stylesheet" href="styles/main.css">
<script>
var config = {"monospaceLinks":false,"cleverLinks":false,"applicationName":"SimpleDDP","disqus":"","googleAnalytics":"","openGraph":{"title":"SimpleDDP Docs","type":"website","image":"https://github.com/Gregivy/simpleddp/raw/2.x.x/simpleddp.png","site_name":"SimpleDDP Docs","url":""},"meta":{"title":"SimpleDDP Docs","description":"SimpleDDP Docs","keyword":"ddp, simpleddp, websocket, meteor"},"linenums":true,"default":{}};
</script>
</head>
<body>
<div id="wrap" class="clearfix">
<div class="navigation">
<h3 class="applicationName"><a href="index.html">SimpleDDP</a></h3>
<button id="menuToggle" class="btn btn-link btn-lg menu-toggle">
<span class="glyphicon glyphicon-menu-hamburger"></span>
</button>
<div class="search">
<input id="search" type="text" class="form-control input-md" placeholder="Search...">
</div>
<ul class="list">
<li class="item" data-name="ddpCollection">
<span class="title ">
<a href="ddpCollection.html">ddpCollection</a>
</span>
<ul class="members itemMembers">
</ul>
<ul class="typedefs itemMembers">
</ul>
<ul class="typedefs itemMembers">
</ul>
<ul class="methods itemMembers">
<span class="subtitle">Methods</span>
<li class="parent " data-name="ddpCollection#exportData"><a href="ddpCollection.html#exportData">exportData</a></li>
<li class="parent " data-name="ddpCollection#fetch"><a href="ddpCollection.html#fetch">fetch</a></li>
<li class="parent " data-name="ddpCollection#filter"><a href="ddpCollection.html#filter">filter</a></li>
<li class="parent " data-name="ddpCollection#importData"><a href="ddpCollection.html#importData">importData</a></li>
<li class="parent " data-name="ddpCollection#onChange"><a href="ddpCollection.html#onChange">onChange</a></li>
<li class="parent " data-name="ddpCollection#reactive"><a href="ddpCollection.html#reactive">reactive</a></li>
</ul>
<ul class="events itemMembers">
</ul>
</li>
<li class="item" data-name="ddpEventListener">
<span class="title ">
<a href="ddpEventListener.html">ddpEventListener</a>
</span>
<ul class="members itemMembers">
</ul>
<ul class="typedefs itemMembers">
</ul>
<ul class="typedefs itemMembers">
</ul>
<ul class="methods itemMembers">
<span class="subtitle">Methods</span>
<li class="parent " data-name="ddpEventListener#start"><a href="ddpEventListener.html#start">start</a></li>
<li class="parent " data-name="ddpEventListener#stop"><a href="ddpEventListener.html#stop">stop</a></li>
</ul>
<ul class="events itemMembers">
</ul>
</li>
<li class="item" data-name="ddpOnChange">
<span class="title ">
<a href="ddpOnChange.html">ddpOnChange</a>
</span>
<ul class="members itemMembers">
</ul>
<ul class="typedefs itemMembers">
</ul>
<ul class="typedefs itemMembers">
</ul>
<ul class="methods itemMembers">
<span class="subtitle">Methods</span>
<li class="parent " data-name="ddpOnChange#start"><a href="ddpOnChange.html#start">start</a></li>
<li class="parent " data-name="ddpOnChange#stop"><a href="ddpOnChange.html#stop">stop</a></li>
</ul>
<ul class="events itemMembers">
</ul>
</li>
<li class="item" data-name="ddpReactiveCollection">
<span class="title ">
<a href="ddpReactiveCollection.html">ddpReactiveCollection</a>
</span>
<ul class="members itemMembers">
</ul>
<ul class="typedefs itemMembers">
</ul>
<ul class="typedefs itemMembers">
</ul>
<ul class="methods itemMembers">
<span class="subtitle">Methods</span>
<li class="parent " data-name="ddpReactiveCollection#_updateReactiveObjects"><a href="ddpReactiveCollection.html#_updateReactiveObjects">_updateReactiveObjects</a></li>
<li class="parent " data-name="ddpReactiveCollection#count"><a href="ddpReactiveCollection.html#count">count</a></li>
<li class="parent " data-name="ddpReactiveCollection#data"><a href="ddpReactiveCollection.html#data">data</a></li>
<li class="parent " data-name="ddpReactiveCollection#map"><a href="ddpReactiveCollection.html#map">map</a></li>
<li class="parent " data-name="ddpReactiveCollection#onChange"><a href="ddpReactiveCollection.html#onChange">onChange</a></li>
<li class="parent " data-name="ddpReactiveCollection#one"><a href="ddpReactiveCollection.html#one">one</a></li>
<li class="parent " data-name="ddpReactiveCollection#reduce"><a href="ddpReactiveCollection.html#reduce">reduce</a></li>
<li class="parent " data-name="ddpReactiveCollection#settings"><a href="ddpReactiveCollection.html#settings">settings</a></li>
<li class="parent " data-name="ddpReactiveCollection#sort"><a href="ddpReactiveCollection.html#sort">sort</a></li>
<li class="parent " data-name="ddpReactiveCollection#start"><a href="ddpReactiveCollection.html#start">start</a></li>
<li class="parent " data-name="ddpReactiveCollection#stop"><a href="ddpReactiveCollection.html#stop">stop</a></li>
</ul>
<ul class="events itemMembers">
</ul>
</li>
<li class="item" data-name="ddpReactiveDocument">
<span class="title ">
<a href="ddpReactiveDocument.html">ddpReactiveDocument</a>
</span>
<ul class="members itemMembers">
</ul>
<ul class="typedefs itemMembers">
</ul>
<ul class="typedefs itemMembers">
</ul>
<ul class="methods itemMembers">
<span class="subtitle">Methods</span>
<li class="parent " data-name="ddpReactiveDocument#data"><a href="ddpReactiveDocument.html#data">data</a></li>
<li class="parent " data-name="ddpReactiveDocument#onChange"><a href="ddpReactiveDocument.html#onChange">onChange</a></li>
<li class="parent " data-name="ddpReactiveDocument#settings"><a href="ddpReactiveDocument.html#settings">settings</a></li>
<li class="parent " data-name="ddpReactiveDocument#start"><a href="ddpReactiveDocument.html#start">start</a></li>
<li class="parent " data-name="ddpReactiveDocument#stop"><a href="ddpReactiveDocument.html#stop">stop</a></li>
</ul>
<ul class="events itemMembers">
</ul>
</li>
<li class="item" data-name="ddpReducer">
<span class="title ">
<a href="ddpReducer.html">ddpReducer</a>
</span>
<ul class="members itemMembers">
</ul>
<ul class="typedefs itemMembers">
</ul>
<ul class="typedefs itemMembers">
</ul>
<ul class="methods itemMembers">
<span class="subtitle">Methods</span>
<li class="parent " data-name="ddpReducer#data"><a href="ddpReducer.html#data">data</a></li>
<li class="parent " data-name="ddpReducer#doReduce"><a href="ddpReducer.html#doReduce">doReduce</a></li>
<li class="parent " data-name="ddpReducer#onChange"><a href="ddpReducer.html#onChange">onChange</a></li>
<li class="parent " data-name="ddpReducer#start"><a href="ddpReducer.html#start">start</a></li>
<li class="parent " data-name="ddpReducer#stop"><a href="ddpReducer.html#stop">stop</a></li>
</ul>
<ul class="events itemMembers">
</ul>
</li>
<li class="item" data-name="ddpSubscription">
<span class="title ">
<a href="ddpSubscription.html">ddpSubscription</a>
</span>
<ul class="members itemMembers">
</ul>
<ul class="typedefs itemMembers">
</ul>
<ul class="typedefs itemMembers">
</ul>
<ul class="methods itemMembers">
<span class="subtitle">Methods</span>
<li class="parent " data-name="ddpSubscription#isOn"><a href="ddpSubscription.html#isOn">isOn</a></li>
<li class="parent " data-name="ddpSubscription#isReady"><a href="ddpSubscription.html#isReady">isReady</a></li>
<li class="parent " data-name="ddpSubscription#isStopped"><a href="ddpSubscription.html#isStopped">isStopped</a></li>
<li class="parent " data-name="ddpSubscription#nosub"><a href="ddpSubscription.html#nosub">nosub</a></li>
<li class="parent " data-name="ddpSubscription#onNosub"><a href="ddpSubscription.html#onNosub">onNosub</a></li>
<li class="parent " data-name="ddpSubscription#onReady"><a href="ddpSubscription.html#onReady">onReady</a></li>
<li class="parent " data-name="ddpSubscription#ready"><a href="ddpSubscription.html#ready">ready</a></li>
<li class="parent " data-name="ddpSubscription#remove"><a href="ddpSubscription.html#remove">remove</a></li>
<li class="parent " data-name="ddpSubscription#restart"><a href="ddpSubscription.html#restart">restart</a></li>
<li class="parent " data-name="ddpSubscription#start"><a href="ddpSubscription.html#start">start</a></li>
<li class="parent " data-name="ddpSubscription#stop"><a href="ddpSubscription.html#stop">stop</a></li>
</ul>
<ul class="events itemMembers">
</ul>
</li>
<li class="item" data-name="DDPClient">
<span class="title ">
<a href="simpleDDP.html">DDPClient</a>
</span>
<ul class="members itemMembers">
<span class="subtitle">Members</span>
<li class="parent " data-name="DDPClient#collections"><a href="simpleDDP.html#collections">collections</a></li>
<li class="parent " data-name="DDPClient#connected"><a href="simpleDDP.html#connected">connected</a></li>
</ul>
<ul class="typedefs itemMembers">
</ul>
<ul class="typedefs itemMembers">
</ul>
<ul class="methods itemMembers">
<span class="subtitle">Methods</span>
<li class="parent " data-name="DDPClient#apply"><a href="simpleDDP.html#apply">apply</a></li>
<li class="parent " data-name="DDPClient#call"><a href="simpleDDP.html#call">call</a></li>
<li class="parent " data-name="DDPClient#clearData"><a href="simpleDDP.html#clearData">clearData</a></li>
<li class="parent " data-name="DDPClient#collection"><a href="simpleDDP.html#collection">collection</a></li>
<li class="parent " data-name="DDPClient#connect"><a href="simpleDDP.html#connect">connect</a></li>
<li class="parent " data-name="DDPClient#disconnect"><a href="simpleDDP.html#disconnect">disconnect</a></li>
<li class="parent " data-name="DDPClient#exportData"><a href="simpleDDP.html#exportData">exportData</a></li>
<li class="parent " data-name="DDPClient#importData"><a href="simpleDDP.html#importData">importData</a></li>
<li class="parent " data-name="DDPClient#markAsReady"><a href="simpleDDP.html#markAsReady">markAsReady</a></li>
<li class="parent " data-name="DDPClient#on"><a href="simpleDDP.html#on">on</a></li>
<li class="parent " data-name="DDPClient#stopChangeListeners"><a href="simpleDDP.html#stopChangeListeners">stopChangeListeners</a></li>
<li class="parent " data-name="DDPClient#sub"><a href="simpleDDP.html#sub">sub</a></li>
<li class="parent " data-name="DDPClient#subscribe"><a href="simpleDDP.html#subscribe">subscribe</a></li>
</ul>
<ul class="events itemMembers">
</ul>
</li>
</ul>
</div>
<div class="main">
<h1 class="page-title" data-filename="ddpCollection.html">Class: ddpCollection</h1>
<section>
<header>
<div class="header content-size">
<h2>ddpCollection
</h2>
<div class="class-description"><p>DDP collection class.</p></div>
</div>
</header>
<article class="content-size">
<div class="container-overview">
<dt>
<div class="nameContainer">
<h4 class="name" id="ddpCollection">
<a class="share-icon" href="#ddpCollection"><span class="glyphicon glyphicon-link"></span></a>
<span class="">
new ddpCollection
</span>
<span class="signature">(name, server)</span>
</h4>
</div>
</dt>
<dd>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>name</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">
<p>Collection name.</p></td>
</tr>
<tr>
<td class="name"><code>server</code></td>
<td class="type">
<span class="param-type"><a href="simpleDDP.html">DDPClient</a></span>
</td>
<td class="description last">
<p>DDPClient instance.</p></td>
</tr>
</tbody>
</table>
<dl class="details">
</dl>
</dd>
</div>
<h3 class="subsection-title">Classes</h3>
<dl class="clearfix summary-list list-classes">
<dt class=""><a href="ddpCollection.html">ddpCollection</a></dt>
</dl>
<h3 class="subsection-title">Methods</h3>
<dl class="list-methods">
<dt>
<div class="nameContainer">
<h4 class="name" id="exportData">
<a class="share-icon" href="#exportData"><span class="glyphicon glyphicon-link"></span></a>
<span class="">
exportData
</span>
<span class="signature">(<span class="optional">format</span>)</span><span class="type-signature">string | Object</span>
</h4>
</div>
</dt>
<dd>
<div class="description">
<p>Exports data from the collection.</p>
</div>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>format</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="default">
'string'
</td>
<td class="description last">
<span class="optional">optional</span>
<p>If 'string' then returns EJSON string, if 'raw' returns js object.</p></td>
</tr>
</tbody>
</table>
<dl class="details">
</dl>
<h5>Returns:</h5>
<table class="params">
<thead>
<tr>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="type">
string
|
Object
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
</dd>
<dt>
<div class="nameContainer">
<h4 class="name" id="fetch">
<a class="share-icon" href="#fetch"><span class="glyphicon glyphicon-link"></span></a>
<span class="">
fetch
</span>
<span class="signature">(<span class="optional">settings</span>)</span><span class="type-signature">Object</span>
</h4>
</div>
</dt>
<dd>
<div class="description">
<p>Returns collection data based on filter and on passed settings. Supports skip, limit and sort.
Order is 'filter' then 'sort' then 'skip' then 'limit'.</p>
</div>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>settings</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="default">
{skip:0,limit:Infinity,sort:null}
</td>
<td class="description last">
<span class="optional">optional</span>
<p>Skip and limit are numbers or Infinity,
sort is a standard js array sort function.</p></td>
</tr>
</tbody>
</table>
<dl class="details">
</dl>
<h5>Returns:</h5>
<table class="params">
<thead>
<tr>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="type">
Object
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
</dd>
<dt>
<div class="nameContainer">
<h4 class="name" id="filter">
<a class="share-icon" href="#filter"><span class="glyphicon glyphicon-link"></span></a>
<span class="">
filter
</span>
<span class="signature">(f)</span><span class="type-signature">this</span>
</h4>
</div>
</dt>
<dd>
<div class="description">
<p>Allows to specify specific documents inside the collection for reactive data and fetching.</p>
</div>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>f</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="description last">
<p>Filter function, recieves as arguments object, index and array.</p></td>
</tr>
</tbody>
</table>
<dl class="details">
</dl>
<h5>Returns:</h5>
<table class="params">
<thead>
<tr>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="type">
this
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
</dd>
<dt>
<div class="nameContainer">
<h4 class="name" id="importData">
<a class="share-icon" href="#importData"><span class="glyphicon glyphicon-link"></span></a>
<span class="">
importData
</span>
<span class="signature">(data)</span>
</h4>
</div>
</dt>
<dd>
<div class="description">
<p>Imports data inside the collection and emits all relevant events.
Both string and JS object types are supported.</p>
</div>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>data</code></td>
<td class="type">
<span class="param-type">string</span>
|
<span class="param-type">Object</span>
</td>
<td class="description last">
<p>EJSON string or EJSON or js object.</p></td>
</tr>
</tbody>
</table>
<dl class="details">
</dl>
</dd>
<dt>
<div class="nameContainer">
<h4 class="name" id="onChange">
<a class="share-icon" href="#onChange"><span class="glyphicon glyphicon-link"></span></a>
<span class="">
onChange
</span>
<span class="signature">(f, filter)</span><span class="type-signature">Object</span>
</h4>
</div>
</dt>
<dd>
<div class="description">
<p>Returns change observer.</p>
</div>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>f</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="description last">
</td>
</tr>
<tr>
<td class="name"><code>filter</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="description last">
</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-see">See:</dt>
<dd class="tag-see">
<ul>
<li><a href="ddpOnChange.html">ddpOnChange</a></li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<table class="params">
<thead>
<tr>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="type">
Object
</td>
<td class="description last"><ul>
<li>@see ddpOnChange</li>
</ul></td>
</tr>
</tbody>
</table>
</dd>
<dt>
<div class="nameContainer">
<h4 class="name" id="reactive">
<a class="share-icon" href="#reactive"><span class="glyphicon glyphicon-link"></span></a>
<span class="">
reactive
</span>
<span class="signature">(<span class="optional">settings</span>)</span><span class="type-signature">Object</span>
</h4>
</div>
</dt>
<dd>
<div class="description">
<p>Returns reactive collection object.</p>
</div>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>settings</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="default">
{skip:0,limit:Infinity,sort:null}
</td>
<td class="description last">
<span class="optional">optional</span>
</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-see">See:</dt>
<dd class="tag-see">
<ul>
<li><a href="ddpReactiveCollection.html">ddpReactiveCollection</a></li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<table class="params">
<thead>
<tr>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="type">
Object
</td>
<td class="description last"><ul>
<li>@see ddpReactiveCollection</li>
</ul></td>
</tr>
</tbody>
</table>
</dd>
</dl>
</article>
</section>
<footer class="content-size">
<div class="footer">
Documentation generated by <a target="_blank" href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.3</a> on Wed Aug 07 2019 02:35:33 GMT+0300 (MSK)
</div>
</footer>
</div>
</div>
<script>prettyPrint();</script>
<script src="scripts/main.js"></script>
</body>
</html>