diff --git a/pouchDB/pouch-0.1.d.ts b/pouchDB/pouch-0.1.d.ts
new file mode 100644
index 000000000..a80fdc955
--- /dev/null
+++ b/pouchDB/pouch-0.1.d.ts
@@ -0,0 +1,213 @@
+// Type definitions for pouch.js
+
+interface PouchOptions {
+ name?: string;
+ adapter?: string;
+}
+
+interface PouchError {
+ status: number;
+ error: string;
+ reason: string;
+}
+
+interface PouchApi {
+ id(): string;
+}
+
+interface PouchInfoResponse {
+ db_name: string;
+ doc_count: number;
+ update_seq: string;
+}
+
+interface PouchApi {
+ info(callback: (err: PouchError, res: PouchInfoResponse) => void): void;
+}
+
+interface PouchGetOptions {
+ rev?: string;
+ revs?: bool;
+ revs_info?: bool;
+ conflicts?: bool;
+ attachments?: bool;
+}
+
+interface PouchGetResponse {
+ _id: string;
+ _rev: string;
+ _attachments: any;
+}
+
+interface PouchAllDocsOptions {
+ startkey?: string;
+ endKey?: string;
+ descending?: bool;
+ include_docs?: bool;
+ conflicts?: bool;
+}
+
+interface PouchAllDocsItem {
+ id: string;
+ key: string;
+ value: any;
+}
+
+interface PouchAllDocsResponse {
+ total_rows: number;
+ rows: PouchAllDocsItem[];
+}
+
+interface PouchApi {
+ //
+ // get == select by id
+ //
+ get(id: string, opts: PouchGetOptions, callback: (err: PouchError, res: PouchGetResponse) => void): void;
+ get(id: string, callback: (err: PouchError, res: PouchGetResponse) => void): void;
+ allDocs(opts: PouchAllDocsOptions, callback: (err: PouchError, res: PouchAllDocsResponse) => void): void;
+ allDocs(callback: (err: PouchError, res: PouchAllDocsResponse) => void): void;
+}
+
+interface PouchUpdateOptions {
+ new_edits: bool;
+}
+
+interface PouchUpdateResponse {
+ ok: bool;
+ id: string;
+ rev: string;
+}
+
+interface PouchApi {
+ bulkDocs(req, opts: PouchUpdateOptions, callback: (err: PouchError, res: PouchUpdateResponse[]) => void): void;
+ bulkDocs(req, callback: (err: PouchError, res: PouchUpdateResponse[]) => void): void;
+ //
+ // post == insert (doc does not contain an _id)
+ //
+ post(doc: any, opts: PouchUpdateOptions, callback: (err: PouchError, res: PouchUpdateResponse) => void): void;
+ post(doc: any, callback: (err: PouchError, res: PouchUpdateResponse) => void): void;
+ //
+ // put == update (doc DOES contain an _id)
+ //
+ put(doc, opts: PouchUpdateOptions, callback: (err: PouchError, res: PouchUpdateResponse) => void): void;
+ put(doc, callback: (err: PouchError, res: PouchUpdateResponse) => void): void;
+ //
+ // remove == delete
+ //
+ remove(doc, opts: PouchUpdateOptions, callback: (err: PouchError, res: PouchUpdateResponse) => void): void;
+ remove(doc, callback: (err: PouchError, res: PouchUpdateResponse) => void): void;
+}
+
+interface PouchFilter {
+ map: (doc: any) => void;
+ reduce?: (key: string, value: any) => any;
+}
+
+interface PouchQueryOptions {
+ complete?: any;
+ include_docs?: bool;
+ error?: (err: PouchError) => void;
+ descending?: bool;
+ reduce?: bool;
+}
+
+interface PouchQueryResponse {
+ rows: any[];
+}
+
+interface PouchApi {
+ //
+ // query == select by other criteria
+ //
+ query(fun: string, opts: PouchQueryOptions, callback: (err: PouchError, res: PouchQueryResponse) => void): void;
+ query(fun: string, callback: (err: PouchError, res: PouchQueryResponse) => void): void;
+ query(fun: PouchFilter, opts: PouchQueryOptions, callback: (err: PouchError, res: PouchQueryResponse) => void): void;
+ query(fun: PouchFilter, callback: (err: PouchError, res: PouchQueryResponse) => void): void;
+}
+
+interface PouchAttachmentOptions {
+ decode?: bool;
+}
+
+interface PouchApi {
+ getAttachment(id: string, opts: PouchAttachmentOptions, callback: (err: PouchError, res: any) => void): void;
+ getAttachment(id: string, callback: (err: PouchError, res: any) => void): void;
+ putAttachment(id: string, rev: string, doc: any, type: string, callback: (err: PouchError, res: PouchUpdateResponse) => void): void;
+ removeAttachment(id: string, rev: string, callback: (err: PouchError, res: PouchUpdateResponse) => void): void;
+}
+
+interface PouchCancellable {
+ cancel: () => void;
+}
+
+interface PouchChangesOptions {
+ onChange: (change: PouchChange) => void;
+ complete?: (err: PouchError, res: PouchChanges) => void;
+ seq?: number;
+ since?: number;
+ descending?: bool;
+ filter?: PouchFilter;
+ continuous?: bool;
+ include_docs?: bool;
+ conflicts?: bool;
+}
+
+interface PouchChange {
+ changes: any;
+ doc: PouchGetResponse;
+ id: string;
+ seq: number;
+}
+
+interface PouchChanges {
+ results: PouchChange[];
+}
+
+interface PouchApi {
+ changes(opts: PouchChangesOptions, callback: (err: PouchError, res: PouchChanges) => void): PouchCancellable;
+ changes(callback: (err: PouchError, res: PouchChanges) => void): PouchCancellable;
+}
+
+interface PouchRevsDiffOptions {
+}
+
+interface PouchReplicateOptions {
+ continuous?: bool;
+ onChange?: (any) => void;
+ filter?: any; // Can be either string or PouchFilter
+ complete?: (err: PouchError, res: PouchChanges) => void;
+}
+
+interface PouchReplicateResponse {
+ ok: bool;
+ start_time: Date;
+ end_time: Date;
+ docs_read: number;
+ docs_written: number;
+}
+
+interface PouchReplicate {
+ from(url: string, opts: PouchReplicateOptions, callback: (err: PouchError, res: PouchReplicateResponse) => void): PouchCancellable;
+ from(url: string, callback: (err: PouchError, res: PouchReplicateResponse) => void): PouchCancellable;
+ to(dbName: string, opts: PouchReplicateOptions, callback: (err: PouchError, res: PouchReplicateResponse) => void): PouchCancellable;
+ to(dbName: string, callback: (err: PouchError, res: PouchReplicateResponse) => void): PouchCancellable;
+}
+
+interface PouchApi {
+ revsDiff(req: any, opts: PouchRevsDiffOptions, callback: (missing: any) => void): void;
+ revsDiff(req: any, callback: (missing: any) => void): void;
+ replicate: PouchReplicate;
+}
+
+interface Pouch extends PouchApi {
+ (name: string, opts: PouchOptions, callback: (err: PouchError, res: Pouch) => void ): Pouch;
+ (name: string, callback: (err: PouchError, res: Pouch) => void ): Pouch;
+ destroy(name: string, callback: (err: PouchError) => void): void;
+}
+
+var Pouch: Pouch;
+//
+// emit is the function that the PouchFilter.map function should call in order to add a particular item to
+// a filter view.
+//
+declare function emit(key: any, value: any);
diff --git a/pouchDB/pouch-tests.ts b/pouchDB/pouch-tests.ts
new file mode 100644
index 000000000..e5dc7bbe6
--- /dev/null
+++ b/pouchDB/pouch-tests.ts
@@ -0,0 +1,142 @@
+///