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

Question: Is it possible to list rows in a database? #31

Closed
jeffandersen opened this issue Jan 12, 2021 · 2 comments
Closed

Question: Is it possible to list rows in a database? #31

jeffandersen opened this issue Jan 12, 2021 · 2 comments

Comments

@jeffandersen
Copy link

I'm trying to understand the hierarchy of the Nishan client, and I'm not 100% sure how to query the data I'm after.
My page structure is such:

  • Top level page
    • Nested database
      • Row A
      • Row B
      • Row C
    • Other nested page

I want to be able to retrieve Row A, Row B, Row C as entries, but after reviewing the code I'm not sure this is exposed?

Thanks in advance

@Devorein
Copy link
Owner

Devorein commented Jan 13, 2021

Here is a little snippet of what could be the answer

First method

const {collection_view_page} = await space.getTRootPages((root_page)=>root_page.id === page_id); // You can use any other criteria
const cvp = collection_view_page.get("page_id");
if(cvp){
	const collection = await cvp.getCollection();
	const rows = await collection.getPages((page)=>true); // All the rows of the database is passed as a parameter to this callback, using a truthy value with return that row page in the result array

Second method

const collections = await space.getRootCollections((collection )=>collection.id === collection_id); // You can use any other criteria 
const collection = collection.get("collection_id");
if(collection){
	const rows = await collection.getPages((page)=>true) // All the rows of the database is passed as a parameter to this callback, using a truthy value with return that row page in the result array
}

Hope this helps

@Devorein Devorein pinned this issue Jan 13, 2021
@Devorein
Copy link
Owner

I hope the above solution worked. I'm closing the issue for now. If you face any further problems please reopen the issue.

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

No branches or pull requests

2 participants