# \[Deprecated\] Exclude databases from search via script

**URL:** <https://community.fibery.io/t/deprecated-exclude-databases-from-search-via-script/5287>\
**Category:** Get Help\
**Created:** [October 12, 2023, 7:47pm UTC](https://community.fibery.io/t/deprecated-exclude-databases-from-search-via-script/5287 "2023-10-12T19:47:15Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![YvetteLans](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/yvettelans/32/6101_2.png) [@YvetteLans](https://community.fibery.io/u/YvetteLans)\
**Post date:** [October 12, 2023, 7:47pm UTC](https://community.fibery.io/t/deprecated-exclude-databases-from-search-via-script/5287/1 "2023-10-12T19:47:15Z")

</div>

Hi guys,

Found [the workaround to exclude databases from search](https://the.fibery.io/@public/search/NfW9m#Public_Roadmap/Roadmap_Item/Exclude-a-Database-from-search-results-177) via API.

Since we have hundred databases, we want to be easily able to exclude/include. I’m trying to create buttons for that.

So I have two buttons: include and exclude. I have the APP\_NAME/TYPE\_NAME stored in a database → field name = SpaceDatabase

I’ve managed to write the script that indeed excludes the database from search; but in this example the Space/Database is fixed (DB acceleright/Documentatie).

```auto
const http = context.getService("http");

await http.postAsync("https://acceleright.fibery.io/api/commands", {
    headers: {
        "Content-type": "application/json",
        Authorization: "Token xxx",
    },
    body: [
        {
            command: "fibery.schema/batch",
            args: {
                commands: [
                    {
                        command: "schema.type/set-meta",
                        args: {
                            name: "DB acceleright/Documentatie",
                            key: "search/disabled",
                            value: true,
                        },
                    },
                ],
            },
        },
    ],
});

```

What I’m trying to do, is getting the variable SpaceName in this script. It shouldn’t be that hard but I got stuck since I’m not a script queen 🙈

 ![image](https://us1.discourse-cdn.com/flex020/uploads/fibery/original/2X/d/d0a311144016b867f10da07b152d7aa5a1886d32.png)

Does somebody has the magic script for me? Tried several things but with no good result.

Thanks!

---

<div class="post-metadata">

**Author:** ![Chr1sG](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/chr1sg/32/3941_2.png) [@Chr1sG](https://community.fibery.io/u/Chr1sG)\
**Post date:** [October 13, 2023, 6:11am UTC](https://community.fibery.io/t/deprecated-exclude-databases-from-search-via-script/5287/2 "2023-10-13T06:11:00Z")

</div>

If you want to use variables in a command, you need to pass them in as parameters, e.g.

```auto
commands: [
    {
        command: "schema.type/set-meta",
        args: {
            name: "$database",
            key: "search/disabled",
            value: true,
        },
        params: {
            "$database": SpaceDatabase
        }
    },
],

```

This assumes you have previously executed a function to set the value for SpaceDatabase.

P.s. you don’t need to use the http call to execute a command in this way. The Fibery service includes a function: ‘executeSingleCommand’ which is much easier to use, and doesn’t require storing the API key in the script e.g.

```auto
const fibery = context.getService('fibery');
await fibery.executeSingleCommand({
    command: "fibery.schema/batch",
    args: {
        commands: [
            {
                command: "schema.type/set-meta",
                args: {
                    .
                    .
                    .
                    .

```

---

<div class="post-metadata">

**Author:** ![YvetteLans](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/yvettelans/32/6101_2.png) [@YvetteLans](https://community.fibery.io/u/YvetteLans)\
**Post date:** [October 14, 2023, 12:26pm UTC](https://community.fibery.io/t/deprecated-exclude-databases-from-search-via-script/5287/3 "2023-10-14T12:26:39Z")

</div>

Awesome, thanks again 🤩!

I don’t know why, but it didn’t worked if I used the ‘params’ as you mentioned.

However, this script works:

```auto
const fibery = context.getService('fibery');

for (const entity of args.currentEntities) {
    const SpaceDatabase = entity["SpaceDatabase"];
    await fibery.executeSingleCommand({
        command: "fibery.schema/batch",
        args: {
            commands: [{
                command: "schema.type/set-meta",
                args: {
                    name: SpaceDatabase,
                    key: "search/disabled",
                    value: true,
                }
            }]
        }
    });
};

```

Currently I’ve made a button to run the script and exclude/include a database from search.

Ideally I want to have a database with all active databases/spaces in the workspace. So that you have an up to date overview and can use the buttons to inlude/exclude from search. We would then also use that database to link our documentation + SOP’s to a specific database/space.

Would be awesome if this would be native functionality for admins or app in Fibery.

But for now: is there maybe is a way via script (+ on schedule automation?) to have an overview of all active databases/spaces in a workspace (plus ideally if search/disabled is true or false)?

---

<div class="post-metadata">

**Author:** ![Minh\_Tri\_Do\_Hang](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/minh_tri_do_hang/32/6791_2.png) [@Minh\_Tri\_Do\_Hang](https://community.fibery.io/u/Minh_Tri_Do_Hang)\
**Post date:** [October 15, 2023, 12:05am UTC](https://community.fibery.io/t/deprecated-exclude-databases-from-search-via-script/5287/4 "2023-10-15T00:05:28Z")

</div>

[https://the.fibery.io/@public/Public\_Roadmap/Roadmap\_Item/Exclude-a-Database-from-search-results-177](https://the.fibery.io/@public/Public_Roadmap/Roadmap_Item/Exclude-a-Database-from-search-results-177)  
Does this relevant on this ? I saw State: Ready for dev already

---

<div class="post-metadata">

**Author:** ![YvetteLans](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/yvettelans/32/6101_2.png) [@YvetteLans](https://community.fibery.io/u/YvetteLans)\
**Post date:** [October 15, 2023, 7:50am UTC](https://community.fibery.io/t/deprecated-exclude-databases-from-search-via-script/5287/5 "2023-10-15T07:50:25Z")

</div>

Thanks! It was ‘Icebox’ at the beginning of this week because there was a workaround. But I think they may changed something after my chat with support 🙂

But even if the ‘normal solution’ goes live, I still like to have a complete overview of all spaces/databases in our workspace.

Since we can then easily fix permissions via groups, link our docs en SOPs and have an overview of which databases are excluded from search yes/no.

If you only have a setting per database, then it’s kinda hard to have overview since we have 100+ databases.

---

<div class="post-metadata">

**Author:** ![antoniokov](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/antoniokov/32/201_2.png) [@antoniokov](https://community.fibery.io/u/antoniokov)\
**Post date:** [January 18, 2024, 2:32pm UTC](https://community.fibery.io/t/deprecated-exclude-databases-from-search-via-script/5287/6 "2024-01-18T14:32:15Z")

</div>

The “normal solution” is here: [Jan 18, 2024 / Entity permissions, exclude DBs from search](https://community.fibery.io/t/jan-18-2024-entity-permissions-exclude-dbs-from-search/5710).

 ![exclude-database-from-search](https://us1.discourse-cdn.com/flex020/uploads/fibery/original/2X/6/609739d330fb42a677131d011733f1d7bcfec333.png)

If you have used [the script](https://community.fibery.io/t/exclude-databases-from-search-via-script/5287), the DBs you excluded should remain excluded.

If you execute the script now, it won’t have any effect, since we are using a different API. The script has been a great proof of concept, but now there are ∞−1 workarounds in Fibery 😅
