db = db.getSiblingDB("statistics");

db.createRole({
  role: "statsReadWrite",
  privileges: [
    {
      resource: {
        db: "statistics",
        collection: "peertube",
      },
      actions: ["insert"],
    },
  ],
  roles: [
    {
      role: "read",
      db: "statistics",
    },
  ],
});

db.createUser({
    user: "stats_user",
    pwd: "@z^VFhN7q%vzit",
    roles: [
      {
        role: 'statsReadWrite',
        db: 'statistics',
      },
    ],
  });

db.createCollection("peertube");