Skip to content
Snippets Groups Projects
database_util.js 1.22 KiB
Newer Older
fcrisafulli-dev's avatar
fcrisafulli-dev committed


export const  dbCreateCollection = async (newCollectionName) => {
    console.log("dbCreateCollection");
    let result = await fetch(
      "http://127.0.0.1:5000/api/v1/create_collection",
      {
        method: "POST", // or 'PUT'
        headers: {
            "Content-Type": "application/json",
        },
        body: JSON.stringify(
            {
                "authenticate":{"username":"test_user","password":"12345"},
                "collection_info":{"collection_name": newCollectionName}
            }
        ),
      }
    )
    .then((response) => response.json())
    .then((response) => {
      if (response["status"] == "success") {
        console.log("dbCreateCollection Success")
        return response["collection_id"];
      }
    });


    return result
};

export const dbGetCollection = async (collection_id) => {
    console.log("dbGetCollection");
    let result = await fetch("http://127.0.0.1:5000//api/v1/get_collection?collection=" + collection_id,)
    .then((response) => response.json())
    .then((response) => {
        console.log(response)
        if (response["status"] == "success") {
            return response["collection"]
        }
    });
    return result;
};

export default dbCreateCollection;