@e2fyi/streams
Version:
Nodejs stream library for various use cases: e.g. Auto-tagging object streams, streaming to mongoDb via mongoose models, etc.
241 lines (83 loc) • 3.93 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Class: MongooseStream</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Class: MongooseStream</h1>
<section>
<header>
<h2>
<span class="ancestors"><a href="module-@e2fyi_streams.html">@e2fyi/streams</a>.</span>MongooseStream</h2>
<div class="class-description"><p>A custom NodeJS Transform stream to mongo via mongoose.</p></div>
</header>
<article>
<div class="container-overview">
<h2>Constructor</h2>
<h4 class="name" id="MongooseStream"><span class="type-signature"></span>new MongooseStream<span class="signature">(opts)</span><span class="type-signature"></span></h4>
<div class="description">
<p>Create a Transform stream which bulkWrite to mongo based on the itemWaterMark.
model (mongoose Model) is a required field.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>opts</code></td>
<td class="type">
<span class="param-type">MongooseStreamSettings</span>
</td>
<td class="description last"><p>Configuration for MongoStream. Default value for <code>itemWaterMark</code> is 50.</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="src_mongoose-stream.js.html">src/mongoose-stream.js</a>, <a href="src_mongoose-stream.js.html#line33">line 33</a>
</li></ul></dd>
</dl>
<h5>Fires:</h5>
<ul>
<li><a href="MongooseStream.html#event:mongoose-bulk-write">MongooseStream#event:mongoose-bulk-write</a></li>
</ul>
<h5>Example</h5>
<pre class="prettyprint"><code>var stream2mongo = new MongooseStream({mode: SomeMongooseModel});
someReadableStreamFromArray([{text: 'abc'}, {text: 'efg'}])
.pipe(stream2mongo) // writes to mongo (while stream are also passthrough)
.pipe(response); // stream same results back to some request</code></pre>
</div>
<h3 class="subsection-title">Extends</h3>
<ul>
<li>stream.Transform</li>
</ul>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-@e2fyi_streams.html">@e2fyi/streams</a></li></ul><h3>Classes</h3><ul><li><a href="module-@e2fyi_streams.DocumentTagger.html">DocumentTagger</a></li><li><a href="module-@e2fyi_streams.MongooseStream.html">MongooseStream</a></li></ul><h3>Events</h3><ul><li><a href="DocumentTagger.html#event:filtered">filtered</a></li><li><a href="MongooseStream.html#event:mongoose-bulk-write">mongoose-bulk-write</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.0</a> on Thu Dec 14 2017 18:22:08 GMT+0800 (+08)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>