Function: newLixFile()
newLixFile(args?
): Promise
<NewLixBlob
>
Creates a new Lix file as a NewLixBlob.
This function bootstraps an in-memory SQLite database with the necessary
schema and metadata to represent a valid Lix project. The resulting
blob is ready to be persisted to disk, IndexedDB, or other storage.
The returned blob has a ._lix
property for immediate access to the
lix identifier and name without needing to open the file.
Parameters
args?
keyValues?
NewStateAll
<LixKeyValue
>[]
Pre-populates the key-value store of the new lix file.
Use this to set initial values for lix_id
, lix_name
, or other custom keys.
If lix_id
or lix_name
are not provided, they will be generated automatically.
Example
keyValues: [
{ key: "lix_name", value: "my-project", lixcol_version_id: "global" },
{ key: "lix_id", value: "custom-id", lixcol_version_id: "global" },
{ key: "my_custom_key", value: "my_custom_value", lixcol_version_id: "global" },
]
Returns
Promise
<NewLixBlob
>
Examples
// Create a new lix file with default values
const blob = await newLixFile();
console.log(blob._lix.id); // e.g. "z2k9j6d"
console.log(blob._lix.name); // e.g. "blue-gorilla"
// Create a new lix file with specific key-values
const blob = await newLixFile({
keyValues: [
{ key: "lix_name", value: "my-project", lixcol_version_id: "global" },
{ key: "lix_id", value: "custom-id", lixcol_version_id: "global" },
{ key: "my_custom_key", value: "my_custom_value", lixcol_version_id: "global" }
],
});
console.log(blob._lix.id); // "custom-id"
console.log(blob._lix.name); // "my-project"