Creating an Admin Dashboard
Explore how to create an admin dashboard in a Meteor.js full-stack application, focusing on displaying book sales data, using MongoDB aggregations for insights, and managing admin authentication. Understand how to subscribe to publications, implement server-side aggregation methods, and render dynamic data in React components.
Let’s create a page where we can view book sales and perform some aggregate functions using MongoDB.
Publishing sales data
Open the imports/api/bookSales/server/publication.js file. On line 2, the BookSales collection is imported for use. A publication is defined on lines 4–6, which we named bookSales.sales. This publication returns a cursor from the BookSales collection of documents in which the paymentStatus field is equal to success.
Subscribing to the sales cursor
After creating a publication, we’ll want to subscribe to the cursor on the client. Open the imports/ui/Sales.jsx file. On line 3, we import the useTracker function. On line 4, we import the BookSales collection. Inside the useTracker function, we subscribe to the publication named bookSales.sales. ...