Indian Cities Database

1.0.5 · abandoned · verified Wed Apr 22

The `indian-cities-database` package offers a structured dataset comprising Indian cities and their respective states, designed for integration into Node.js applications. It provides a static JavaScript array containing city-state objects, which can be directly consumed or used to populate a local MongoDB instance. The current and likely final stable version is 1.0.5, with its last known activity dating back to September 2016, indicating that the package is no longer actively maintained. A key feature is its ability to push this geographical data to MongoDB, complete with a predefined Mongoose schema for streamlined querying. This library simplifies the integration of Indian location data, providing a readily available dataset and tools for database persistence, bypassing the need for manual data sourcing and structuring.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to import the package and access the static `cities` array. Also hints at schema usage.

const indianCitiesDatabase = require('indian-cities-database');

// Get the full list of cities and states
const cities = indianCitiesDatabase.cities;

console.log(`Total cities found: ${cities.length}`);
console.log('First 5 cities:');
cities.slice(0, 5).forEach(city => {
  console.log(`  - ${city.city}, ${city.state}`);
});

// Example of accessing the Mongoose schema (requires Mongoose to be installed separately)
// Note: This won't run without 'mongoose' installed and a MongoDB connection.
// try {
//   const mongoose = require('mongoose');
//   const citySchema = indianCitiesDatabase.citySchema;
//   citySchema.set('collection', 'my_cities_collection');
//   const MyCity = mongoose.model('MyCity', citySchema);
//   console.log('Mongoose City Model created successfully (schema only).');
// } catch (e) {
//   console.warn('Mongoose or MongoDB not available, skipping schema example:', e.message);
// }

view raw JSON →