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

initial public api spec #299

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

initial public api spec #299

wants to merge 1 commit into from

Conversation

jchris
Copy link
Contributor

@jchris jchris commented Oct 15, 2024

This is the test we expect all versions of 1.x to pass. If we break this test, we are talking about 2.0

Let's review and discuss before we merge. These are the main feature areas to specify:

  • Query options and response object shape for db.query(), db.allDocs(), db.changes() and db.subscribe() can be normalized.
  • Metadata like doc._id are implicitly specified here, we can do better
  • We should specify _proof or something similar to give access to the underlying Merkle integrity
  • The history API will come post 1.0 but this is a good context to think about it.

Adding assertions (not removing them) from this test is how we know we are getting close to a new 1.1, 1.2, etc

@jchris
Copy link
Contributor Author

jchris commented Oct 15, 2024

Also relevant are questions about renaming "database" to "document" in which case what do we call the return of const val = document.get('id')?

Candidate names are val (value) rec (record) it (item), any others?

await db.destroy();
});

beforeEach(async function () {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

async () =>

doc = await db.get("test");
query = await db.query<string, Doc>((doc) => doc.foo);
});
it("should be a database instance", function () {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

function =>

// erase the existing test data
await sthis.start();

db = DatabaseFactory("test-reopen-spec", { autoCompact: 100000 });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not fireproof?

Copy link
Contributor

@mabels mabels left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

@mabels
Copy link
Contributor

mabels commented Oct 16, 2024

i would go for this:

const tdb = db.typed<DocType>() // this will not break with the old api
interface TypedItem<T> {
    meta: Meta
    data: T
}
interface TypedDatabase<T> {
    get(key): Result<TypedItem>
    put(typedItem: T| TypedItem<T>): Result<TypedItem<T>>
    query(key: T|AllDocs): Result<TypedItem<T>[]> // we don't need AllDocs
    subscribe(key: T|AllDocs, CB: (TypedItem<T>[]) => Result<void>): Result<Registration>
    // do we need changes?
}

@jchris
Copy link
Contributor Author

jchris commented Oct 16, 2024

I like the suggestion of collection or ledger for what we call "database" now

@jchris jchris marked this pull request as draft October 16, 2024 21:21
@mabels
Copy link
Contributor

mabels commented Nov 11, 2024

Please add the iterator and readstream api to alldocs/query.
If you need help --- ask

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