Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Get values from database #131

Answered by KoditkarVedant
I-SER-I asked this question in Q&A
Discussion options

I want to get all values ​​from the database. But for some reason, i only see the names of the properties, and the values ​​are empty
image

Example Table
image

You must be logged in to vote

@I-SER-I you need to use the Query API on the database to get all values (i.e. rows - pages in the terms of Notion).

Replies: 1 comment 5 replies

Comment options

@I-SER-I you need to use the Query API on the database to get all values (i.e. rows - pages in the terms of Notion).

You must be logged in to vote
5 replies
Comment options

Many thanks

Comment options

@KoditkarVedant I'm stuck in exactly same situation. Could you provide any code example?

Comment options

@KoditkarVedant I'm stuck in exactly same situation. Could you provide any code example?

var queryParams = new DatabasesQueryParameters { Filter = null };
var pages = await client.Databases.QueryAsync(databaseId, queryParams);

source

databaseId u can get on Databases property

Comment options

@I-SER-I This is exactly what I have done:

`
public async IAsyncEnumerable DoSomething()
{
var client = NotionClientFactory.Create(new ClientOptions
{
AuthToken = AuthTokentoken
});

 var queryParams = new DatabasesQueryParameters { Filter = null };
 var pages = await client.Databases.QueryAsync(dbKey, queryParams);
 
 foreach (var Page in pages.Results)
 {
 foreach (var property in Page.Properties.Where(x => x.Value.Type!=PropertyValueType.Title))
 {
 if(property.Value is RelationPropertyValue relationProperty)
 {
 yield return string.Join(",", relationProperty.Relation.Select(x => x.Id.ToString()));
 }
 
 yield return property.Key + " - " + property.Value.Id + " - " + property.Value.Type;
 
 }
 }
 
 }`

When my Notion database looks like this:
image
I should be able to see those related pages but they are not there:
image
Marked filed should give me 'Relation1Page'

Comment options

Ok, solved by myself. Maybe this would be helpfull for anyone in future. In my case there were always empty relations. I had to enable my related table in Notion to use same integration as parent.

Answer selected by I-SER-I
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /