Last active
August 29, 2015 14:15
-
-
Save chandu0101/62013de47bf5ee4d2412 to your computer and use it in GitHub Desktop.
pouchDB scalajs facade
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.scalajs.js | |
import scala.scalajs.js.Dynamic.{literal => json} | |
import scala.scalajs.js.annotation.JSName | |
/** | |
* Created by chandrasekharkode . | |
*/ | |
trait PouchDBAjaxOptions extends js.Object { | |
var cache: Boolean = js.native | |
var headers: String = js.native | |
} | |
object PouchDBAjaxOptions { | |
def apply(cache: Boolean = false, headers: String) = | |
json("cache" -> cache, "headers" -> headers).asInstanceOf[PouchDBAjaxOptions] | |
} | |
trait PouchDBOptions extends js.Object { | |
var auto_compaction: Boolean = js.native | |
var adapter: Boolean = js.native | |
var ajax: PouchDBAjaxOptions = js.native | |
} | |
object PouchDBOptions { | |
def apply(auto_compaction: Boolean = false, adapter: String = null, ajax: PouchDBAjaxOptions = null) = | |
json("auto_compaction" -> auto_compaction, "adapter" -> adapter, "ajax" -> ajax).asInstanceOf[PouchDBOptions] | |
} | |
trait AllDocsOptions extends js.Object { | |
var include_docs: Boolean = js.native | |
var conflicts: Boolean = js.native | |
var attachments: Boolean = js.native | |
var startkey: String = js.native | |
var endkey: String = js.native | |
var inclusive_end: Boolean = js.native | |
var limit: Int = js.native | |
var skip: Int = js.native | |
var descending: Boolean = js.native | |
var key: String = js.native | |
var keys: js.Array[String] = js.native | |
} | |
object AllDocsOptions { | |
def apply( limit: Int = 0,include_docs: Boolean = false,attachments: Boolean = false,keys: js.Array[String] = null,endkey: String = null,skip: Int = 0,inclusive_end: Boolean = false,startkey: String = null,conflicts: Boolean = false,key: String = null,descending: Boolean = false) = | |
json("attachments" -> attachments,"endkey" -> endkey,"key" -> key,"conflicts" -> conflicts,"include_docs" -> include_docs,"keys" -> keys,"skip" -> skip,"startkey" -> startkey,"limit" -> limit,"descending" -> descending,"inclusive_end" -> inclusive_end) | |
} | |
trait EventEmitter extends js.Object { | |
def on(event: String, listner: js.Function1[js.Any, Unit]): this.type = js.native | |
} | |
trait ChangesEventEmitter extends EventEmitter { | |
def cancel(): Unit = js.native | |
} | |
trait ChangesOptions extends js.Object { | |
var include_docs: Boolean = js.native | |
var conflicts: Boolean = js.native | |
var attachments: Boolean = js.native | |
var descending: Boolean = js.native | |
var filter: Boolean = js.native | |
var doc_ids: js.Array[String] = js.native | |
var since: String = js.native | |
var live: Boolean = js.native | |
var limit: Int = js.native | |
var style: String = js.native | |
var view: js.Function = js.native | |
var returnDocs: Boolean = js.native | |
var batch_size: Int = js.native | |
} | |
object ChangesOptions { | |
def apply( since: String = null,limit: Int = 0, | |
include_docs: Boolean = false, | |
style: String = null,attachments: Boolean = false, | |
returnDocs: Boolean = false, | |
view: js.UndefOr[js.Function] = js.undefined, | |
live: Boolean = false,batch_size: Int = 0, | |
conflicts: Boolean = false, | |
filter: Boolean = false,descending: Boolean = false, | |
doc_ids: js.UndefOr[js.Array[String]] = js.undefined) = | |
json("attachments" -> attachments,"view" -> view,"since" -> since,"filter" -> filter,"conflicts" -> conflicts,"include_docs" -> include_docs,"limit" -> limit,"style" -> style,"batch_size" -> batch_size,"descending" -> descending,"doc_ids" -> doc_ids,"returnDocs" -> returnDocs,"live" -> live) | |
} | |
@JSName("PouchDB") | |
class PouchDB extends js.Object { | |
def this(name: String , options: PouchDBOptions = js.native) = this() | |
var name: String = js.native | |
var options: PouchDBOptions = js.native | |
def destroy(options: js.Object = null, callback: js.Function2[String, String, Unit] = null): Unit = js.native | |
def put(doc: js.Object , docId: String = null, docRev: String = null, options: js.Object = null, callback: js.Function2[String, js.Object, Unit] = null ): Unit = js.native | |
def post(doc: js.Object, options: js.Object = null, callback: js.Function2[String, js.Any, Unit] = null): Unit = js.native | |
def get(docId: String , options: js.Object = null, callback: js.Function2[String, js.Object, Unit] = null) : Unit = js.native | |
def remove(doc: js.Object, options: js.Object = null, callback: js.Function2[String, js.Object, Unit] = null) : Unit = js.native | |
def bulkDocs(docs: js.Array[js.Object], options: js.Object = null, callback: js.Function2[String, js.Any, Unit] = null ) : Unit = js.native | |
def allDocs(options: AllDocsOptions = null, callback: js.Function2[String, js.Any, Unit] = null): Unit = js.native | |
def changes(options : ChangesOptions = null) : ChangesEventEmitter = js.native | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment