Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve index.d.ts #125

Merged
merged 4 commits into from
Mar 29, 2017
Merged

improve index.d.ts #125

merged 4 commits into from
Mar 29, 2017

Conversation

Jimmysh
Copy link
Contributor

@Jimmysh Jimmysh commented Mar 29, 2017

export PouchDB for check adapter can use.

const db = new PouchDB('mydb', { adapter: adapter });
return db.info();

export PouchDB for check adapter can use.

const db = new PouchDB('mydb', { adapter: adapter });
return db.info();
@pubkey
Copy link
Owner

pubkey commented Mar 29, 2017

Hi @Jimmysh
I added the param-name to the create-function.
I don't get what the pouchdb-export should do?
There is no collection-method in pouchdb

@Jimmysh
Copy link
Contributor Author

Jimmysh commented Mar 29, 2017

function checkAdapterWorks(adapterName: string) {
  try {
    const db = new PouchDB('testDB', { adapter: adapterName });
    return !!db.info();
  } catch (e) {
  }
  return false;
}
const adapters: {
  name: string,
  entity: any
}[] = [
    { name: 'idb', entity: idb },
    { name: 'websql', entity: websql },
    { name: 'localstorage', entity: localstorage },
    { name: 'memory', entity: memory },
  ];

 const find = _.find(adapters, (adapter: any) => checkAdapterWorks(adapter.name));
    if (find) {
      this.useAdapter = find;
      console.log('current adapter', this.useAdapter);
    } else {
      console.log('don't support');
    }

sample.

EDIT by pubkey: formated code

@pubkey
Copy link
Owner

pubkey commented Mar 29, 2017

You defined the function PouchDB.collection here.
But as far as I know, this function does not exists?

Also your example does not explain why every creator-interface should be public.

Jimmysh added 2 commits March 29, 2017 23:45
export DatabaseCreator for

const creatorArr : creator[] =  [];
const promissArr = creatorArr.map( d => RxDB.create(d));
@pubkey pubkey merged commit 83bee8b into pubkey:master Mar 29, 2017
@pubkey
Copy link
Owner

pubkey commented Mar 29, 2017

Merged, thank you @Jimmysh
Maybe we can find a way to directly import the typings of pouchdb, like this ones

@pubkey
Copy link
Owner

pubkey commented Jul 11, 2017

The last commit was added here by mistake. Just ignore it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants