Skip to content

Latest commit

 

History

History
executable file
·
115 lines (72 loc) · 2.05 KB

districts.md

File metadata and controls

executable file
·
115 lines (72 loc) · 2.05 KB

Districts Usage

Introduction

You can use CommonJS modules or ES modules syntax for importing the District entity.

import { District } from 'states-nepal' // ES6

or

const { District } = require('states-nepal') // CommonJS

By default, english language will be used. In order to use Nepali language, you have to specify while initiating the district object.

import { District } from 'states-nepal'

// English language will be selected by default
const district = new District()

Or, You can specify nepali language :

import { District } from 'states-nepal'

const district = new District('np')

Retrieving Districts

Once you create instance of District, you can retrieve variety of data.

1. Get list of all districts

import { District } from 'states-nepal'

const district = new District()

district.allDistricts()

2. Find district details by unique identifier

import { District } from 'states-nepal'

const district = new District()

district.find(1)

3. Get array of districts by province Id

import { District } from 'states-nepal'

const district = new District()

district.getDistrictsByProvince(2)

4. Get district with largest area

import { District } from 'states-nepal'

const district = new District()

district.largest()

5. Get district with smallest area

import { District } from 'states-nepal'

const district = new District()

district.smallest()

6. Get array of districts with municipalities (having wards no.)

import { District } from 'states-nepal'

const district = new District()

district.getDistrictsWithMunicipalities()

7. Search districts by key and value with exact match option

import { District } from 'states-nepal'

const district = new District()

// examples
district.search('name', 'Arghakhanchi') // (key, value)
district.search('id', 38)
district.search('headquarter', 'Tamghas')

List of options for parameter key:

'id', 'province_id', 'name', 'area_sq_km', 'website', 'headquarter'