Skip to content

Commit

Permalink
Merge pull request #35 from shubhvjain/main
Browse files Browse the repository at this point in the history
mete.title in all docs , new system schema for execuatable scripts... info to excute them still required
  • Loading branch information
shubhvjain authored Jan 27, 2025
2 parents 4b5f624 + cc0114b commit e7bb6c3
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "beanbagdb",
"version": "0.6.0",
"version": "0.6.1",
"description": "A JS library to introduce a schema layer to a No-SQL local database",
"main": "src/index.js",
"module": "src/index.js",
Expand Down
6 changes: 4 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1043,13 +1043,16 @@ async _upgrade_schema_in_bulk(schemas,log_upgrade=false,log_message="Schema Upgr
if (!schema_name) {
throw new Error("Schema name not provided for the blank doc");
}
let dt = this.util_get_now_unix_timestamp()
let title = `${schema_name} document - ${dt}`
let doc = {
data: {},
meta: {
created_on: this.util_get_now_unix_timestamp(),
created_on: dt,
tags: [],
app: {},
link: this.util_generate_random_link(), // there is a link by default. overwrite this if user provided one but only before checking if it is unique
title: title
},
schema: schema_name,
};
Expand Down Expand Up @@ -1088,7 +1091,6 @@ async _upgrade_schema_in_bulk(schemas,log_upgrade=false,log_message="Schema Upgr
console.log(error)
throw new EncryptionError([{message:error.message}])
}

}

/**
Expand Down
46 changes: 46 additions & 0 deletions src/system_schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,48 @@ export const default_app = {
encrypted_fields: [],
},
},
{
name: "system_script",
system_generated: true,
title: "Executable script",
active: true,
version: 0.1,
description: "To create scripts that implement some logic. Can run both on browser and client.",
schema: {
type: "object",
additionalProperties: true,
required: ["script","type","version"],
properties: {
type: {
type: "string",
default:"JS"
},
script: {
type: "string",
description:"The script",
default:""
},
usage:{
type:"string",
description:"Documentation",
default:" "
},
version :{
type:"number",
default:0.1
},
log_execution:{
type:"boolean",
default:false
}
},
},
settings: {
primary_keys: [],
non_editable_fields: [],
encrypted_fields: [],
},
},
],
records: [],
};
Expand All @@ -384,6 +426,10 @@ export const editable_metadata_schema = {
maxLength: 2000,
pattern: "^[a-zA-Z0-9-]+$",
},
title:{
type:"string",
maxLength:10000
}
},
};

Expand Down
4 changes: 2 additions & 2 deletions test/operations.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1371,7 +1371,7 @@ describe("Doc search tests", async () => {
it('all docs', async () => {
try {
let udata = await database3.search({selector:{}})
assert(udata.docs.length==12)
assert(udata.docs.length==13)
} catch (error) {
//console.log(error)
throw error
Expand All @@ -1391,7 +1391,7 @@ describe("Doc search tests", async () => {
it('read docs 2', async () => {
try {
let udata = await database3.search({selector:{"schema":"schema"}})
assert(udata.docs.length==8) // schema,book,setting,key,edge,edge_constraints
assert(udata.docs.length==9) // schema,book,setting,key,edge,edge_constraints
} catch (error) {
//console.log(error)
throw error
Expand Down

0 comments on commit e7bb6c3

Please sign in to comment.