{"size": 860, "ext": "js", "max_stars_repo_path": "services/collections.js", "max_stars_repo_name": "LupitaVelascoMarin02/ProyectoU3DMI", "max_stars_repo_stars_event_min_datetime": "2021-07-19T09:40:44.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T11:08:58.000Z", "max_issues_repo_path": "services/collections.js", "max_issues_repo_name": "LupitaVelascoMarin02/ProyectoU3DMI", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "services/collections.js", "max_forks_repo_name": "LupitaVelascoMarin02/ProyectoU3DMI", "max_forks_repo_forks_event_min_datetime": "2021-05-30T05:50:51.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-15T03:55:53.000Z"}
{"max_stars_count": 2, "max_issues_count": null, "max_forks_count": 5, "avg_line_length": 23.8888888889, "max_line_length": 75, "alphanum_fraction": 0.4709302326}
export const onSnapshot = (ref, callback, options) => {
    ref.onSnapshot((snapshot) => {
        let items = snapshot.docs.map((doc) => {
            const data = doc.data();
            data.id = doc.id;
            return data;
        });
        items = options && options.sort ? items.sort(options.sort) : items;

        callback(items);
    });
};

export const addDoc = (ref, { id, ...data }) => {
    const doc = id ? ref.doc(id) : ref.doc();
    doc.set(data).then(() => {
        console.log("Add new item");
    });
};

export const removeDoc = (ref, id) => {
    ref.doc(id)
        .delete()
        .then(() => {
            console.log(`Removed item: ${id}`);
        });
};

export const updateDoc = (ref, id, data) => {
    ref.doc(id)
        .set(data)
        .then(() => {
            console.log(`Updated item: ${id}`);
        });
};
