-
Notifications
You must be signed in to change notification settings - Fork 54
Get values from database #131
-
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
Beta Was this translation helpful? Give feedback.
All reactions
@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
-
@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).
Beta Was this translation helpful? Give feedback.
All reactions
-
Many thanks
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1
-
@KoditkarVedant I'm stuck in exactly same situation. Could you provide any code example?
Beta Was this translation helpful? Give feedback.
All reactions
-
@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);
databaseId
u can get on Databases
property
Beta Was this translation helpful? Give feedback.
All reactions
-
😕 1
-
@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'
Beta Was this translation helpful? Give feedback.
All reactions
-
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.
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1