Closed egeres closed 1 year ago
Hello, yes I can see that you execute page_create
on db
object.
It works only with no.pages.
at the moment.
In your case:
new_page = Page.create(
parent = LinkTo(from_object=db.obj),
properties = {
"Name": PropertyValue.create("title", "My title")
}
)
created_page = no.pages.page_create(new_page)
The Page object already has parent attr, because it's mandatory. And there is a constrain to use page_create on specific Element objects. Otherwise it would be possible to execute db.page_create(new_page) and db2.page_create(new_page) that creates two identical pages in the same database Another way to append to database described here: https://github.com/lastorel/pytion/discussions/62
Converting to discussion
Accessing databases is pretty straightforward:
And if we run
db.db_query().obj.array
, we can iterate over the entries in a notion database as well as see the properties of each object accessing.properties
retrieves a dictionary with all the info... but I can't find a way to insert a new page in the database? I would have expected the following code to work, but it doesn't: