Appifio Creator · Lesson EM03 · Easy · 15 data-store methods

JSON data store
full methods - params · returns · notes

One notebook per data type. readFile returns a string → you must JSON.parse (EM02). Easy has no admin login - every call needs a valid page session key.

Golden rule: No appendData/readList. To add a row = read notebook → edit object → writeFile the whole notebook. Fields: value is already decoded - missing file → success: false (unlike Aura).

A. Read / write the notebook

appifio_readFile(fileName) · Needs page session key

Job: Read an entire file in the data store.

Params: fileName - e.g. blog.json, settings.json.

const r = await appifio_client.appifio_readFile('blog.json');
// r.data.content = raw string | ""
// r.data.exists = true | false

Returns: { success, data: { content: string, exists: boolean, … } }

Notes: Missing file → success: true, exists: false, content: "" (not 404). JSON → always JSON.parse in try/catch. Unlike Aura: Aura already parses.

appifio_writeFile(fileName, content)

Job: Overwrite or create.

Params: content = a string (usually JSON.stringify(obj, null, 2)).

await appifio_client.appifio_writeFile('blog.json', JSON.stringify(data, null, 2));

Returns: { success: true } or an error with message.

appifio_createFile(fileName, content?)

Job: Create a new file. content defaults to ''.

await appifio_client.appifio_createFile('blog.json', '{"blogs":{},"metadata":{"total":0}}');

Returns: { success: true } - errors if it already exists (unlike writeFile, which overwrites).

B. Delete · restore · rename · copy

appifio_deleteFile(fileName)
await appifio_client.appifio_deleteFile('old.json');

Returns: { success: true } - soft delete (restorable).

appifio_restoreFile(fileName)
await appifio_client.appifio_restoreFile('old.json');

Returns: { success: true } - restore a soft-deleted file.

appifio_hardDeleteFile(fileName)
await appifio_client.appifio_hardDeleteFile('spam.json');

Returns: { success: true }. Notes: Permanent delete - no undo. (Aura often restricts to super admin; Easy only needs a page session key.)

appifio_renameFile(oldName, newName)

Params: Extensions should match (e.g. both .json).

await appifio_client.appifio_renameFile('a.json', 'b.json');

Returns: { success: true }

appifio_copyFile(sourceFile, destFile)
await appifio_client.appifio_copyFile('blog.json', 'blog-backup.json');

Returns: { success: true }

C. Check · list · find

appifio_fileExists(fileName)
const r = await appifio_client.appifio_fileExists('blog.json');
// r.success === true; r.data.exists === true|false

Returns: often success: true with exists - a missing file is not a network error.

appifio_getFileInfo(fileName)
const r = await appifio_client.appifio_getFileInfo('blog.json');
// success: metadata (name, size, time…)
// missing file → success: false
appifio_listFiles(includeDeleted?)

Params: includeDeleted - default false.

const r = await appifio_client.appifio_listFiles();
const r2 = await appifio_client.appifio_listFiles(true); // include soft-deleted

Returns: list of files in the data store (check data / files array by response shape - always check success).

appifio_searchFiles(pattern)

Params: wildcards * and ? on file names.

const r = await appifio_client.appifio_searchFiles('blog-*.json');
appifio_findByName(fileName)

Job: Find by name string (contains / LIKE style).

const r = await appifio_client.appifio_findByName('blog.json');

Easy notes: Client defaults to searching the data store only - does not scan page HTML files. Not the same as Aura’s “exact name only.”

D. Fields (dot-path)

appifio_readField(fileName, fieldPath)

Params: fieldPath - e.g. theme.color, user.profile.name.

const r = await appifio_client.appifio_readField('settings.json', 'theme.color');
if (r.success) {
  const color = r.data.value; // already decoded - do NOT JSON.parse
} else {
  // file or field missing
}

Returns: { success, data: { value } }. Missing file/field → success: false. Aura: often success: true, value: null.

appifio_writeField(fileName, fieldPath, value)

Job: Write one field; may create the file and path levels if missing.

await appifio_client.appifio_writeField('settings.json', 'theme.color', '#ff0000');

Returns: { success: true }. value may be string/number/object - the client sends the right type.

EM03 checklist (15/15): createFile · readFile · writeFile · deleteFile · restoreFile · hardDeleteFile · fileExists · getFileInfo · renameFile · copyFile · listFiles · searchFiles · findByName · readField · writeField

Next

EM04 - Composite: content + route · then EM05 (page files & upload)

Appifio Creator · User guide · EM03