awatson1978:dataset-customers

v1.0.3Published 9 years ago

This package has not had recent updates. Please investigate it's current state before committing to using it in your project.

datasets-customers is a Meteorite package for populating a CustomerAccounts collection with 500 sample customer names and addresses.


Installation

First, install the datasets-customers package from the command line, like so:

meteor add awatson1978:datasets-customers

Default Customer Schema

The user objects are have a fairly simple document schema that looks like the following:

1{
2  FirstName:   String,
3  LastName:  String,
4  FullName: String,
5  Company:  String,
6  Address:  String,
7  City:  String,
8  County:  String,
9  State:  String,
10  ZIP:  String,
11  Phone:  String,
12  Fax:  String,
13  Email:  String,
14  Web:  String,
15  Password:  String,
16  Datetime:  Date,
17  Birthday:  Date,
18  Month: Integer,
19  Week: Integer,
20  Time:  String,
21  Number:  Number,
22  Color:  String
23}

Data/Document Model for Reading Data from Collection

Once done, you'll want to display data from the collection by adding the following templates into your document model. The class names come from Bootstrap v3.

1<template name="customersListTemplate" class="with-bottom-spacer">
2  <div class="padded">
3    <div class="panel panel-info">
4      <div class="panel-heading">
5          <input id="customerSearchInput"type="text" placeholder="Filter..."></input>
6      </div>
7      <ul class="list-group">
8        {{#each customersList}}
9        {{> customersListItemTemplate }}
10        {{/each}}
11      </ul>
12    </div>
13  </div>
14</template>
15<template name="customersListItemTemplate">
16  <li class="list-group-item">{{FirstName}} {{LastName}}</li>
17</template>

Controller for Reading Data from Collection

To dislay data, you'll also need to add the controllers, like so:

1//-------------------------------------------------------------
2// A.  Generate Index
3Template.customersListTemplate.helpers({
4  customersList = function(){
5    return CustomerAccounts.find({
6        $or: [
7            {'FirstName': { $regex: Session.get('account_search_term'), $options: 'i' }},
8            {'LastName':  { $regex: Session.get('account_search_term'), $options: 'i' }}
9        ]
10    },{limit: 10});
11  }  
12});
13

Licensing

MIT License. Use as you wish, including for commercial purposes.