Skip to main content

ensure_session_schema

Function ensure_session_schema 

Source
pub async fn ensure_session_schema<S: StorageAdapter>(
    storage: &S,
) -> Result<(), ParseError>
Expand description

Ensure _SCHEMA carries a _Session entry.

Worth stating why this exists at all. parse-server creates the _SCHEMA document for _Session on its first session write. If parse-rust writes rows into the _Session collection without ever writing that document, a parse-server pointed at the same database has no _Session class to query, and every token parse-rust issued is invisible to it. That is exactly the shared-state property this milestone claims, so it cannot be left to chance.

Reads first and writes only when the class is absent. The read is per session creation, not per request, and it is cheaper than an unconditional upsert on every login. When it does write, it is safe against a class parse-server already created: upsert_schema sets the field keys it is given and leaves _metadata alone, so an existing CLP block survives.