1.1.30 • Published 9 months ago

pouchable v1.1.30

Weekly downloads
5
License
ISC
Repository
github
Last release
9 months ago

@Pouchable

PouchDB simplified by TypeScript Decorators

npm version Build Status Coverage Status Join the chat at https://gitter.im/pouchable

Include the followings in your project

import * as PouchDB from 'pouchdb';
import { Entity, EntityField, Collection } from 'pouchable'

Declare your Entity

/**
 * Posts 
 */
class Post extends Entity {

    @EntityField({
        group: "default",
        name: "title",   
        mandatory: true,
        search_by: [ _.identity ] // need lodash
    })
    title: string;

    @EntityField({
        group: "info",
        name: "author"
    })
    author: string;

    @EntityField({
        group: "info",
        name: "content",
        validate: (v) => { return v.length < 140 } 
    })
    content: string;
}

Declare your collection:

class Posts extends Collection<Post> {
    public getPrefix(): string {
        return "posts";
    }
}

Pouchable and PouchDB at your service:

let db = new PouchDB("default");
let posts = new Posts(db, Post);

posts.insert({ title: "Pouchable is here!!!", author: "Joe"}).then((p) => {
   if (p.title != "Pouchable is here!!!") {
       throw new Error("not really hapenning...");
   }
   console.log(p.title);
}).catch(() => {});

See it in action, our team example:

In this example, you will see a live, up-to-date code that is using pouchable and shows real usecases. https://github.com/sudzy-group/com.sudzy.db

What API is available?

 posts.insert({ title: "Pouchable is here!!!", author: "Joe"}).then().catch(); 
 users.update(u, { street : "23 e 47th, New York, NY"} ).then().catch(); 
 users.get("_user_id").then().catch(); 
 users.remove(u);
 users.find("title", "search title", { startsWith : true });

How Pouchable works under the hood?

Image of Entity

Contributing to Pouchable

Contribution by pull requetsts is more than welcome, feel free to contact us team@sudzy.co

Topics to enhance

  • Change build to gulp
  • A simple web-site that will gather community around us
  • Schema documentation generation - see POC at https://goo.gl/xRVl7p
  • Search keys with multiple properties
  • Default value
  • Error handling when partial update happens
1.1.30

9 months ago

1.1.29

5 years ago

1.1.28

5 years ago

1.1.27

5 years ago

1.1.26

5 years ago

1.1.25

5 years ago

1.1.24

7 years ago

1.1.23

7 years ago

1.1.22

7 years ago

1.1.21

7 years ago

1.1.20

7 years ago

1.1.19

7 years ago

1.1.18

7 years ago

1.1.17

7 years ago

1.1.16

7 years ago

1.1.15

7 years ago

1.1.14

7 years ago

1.1.13

7 years ago

1.1.12

7 years ago

1.1.11

7 years ago

1.1.10

7 years ago

1.1.9

7 years ago

1.1.8

7 years ago

1.1.7

7 years ago

1.1.6

7 years ago

1.1.5

7 years ago

1.1.4

7 years ago

1.1.3

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago