## Javascript examples

## Javascript example: Define a password schema

Each stored password has a set of attributes which are later used to lookup the password. The names and types of the attributes are defined in a schema. The schema is usually defined once globally. Here's how to define a schema:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    const Secret = imports.gi.Secret;

    /* This schema is usually defined once globally */
    const EXAMPLE_SCHEMA = new Secret.Schema.new("org.example.Password",
    	Secret.SchemaFlags.NONE,
    	{
    		"number": Secret.SchemaAttributeType.INTEGER,
    		"string": Secret.SchemaAttributeType.STRING,
    		"even": Secret.SchemaAttributeType.BOOLEAN,
    	}
    );

See the other examples for how to use the schema.