Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/weisjohn/mongoose-latinize
store the latin form of a String field for easy searching / sorting
https://github.com/weisjohn/mongoose-latinize
Last synced: about 2 months ago
JSON representation
store the latin form of a String field for easy searching / sorting
- Host: GitHub
- URL: https://github.com/weisjohn/mongoose-latinize
- Owner: weisjohn
- License: mit
- Created: 2015-10-15T08:08:52.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2019-01-11T10:51:48.000Z (about 6 years ago)
- Last Synced: 2024-11-16T01:12:45.765Z (about 2 months ago)
- Language: JavaScript
- Homepage:
- Size: 148 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mongoose-latinize
store the latin form of a String field for easy searching
### usage
```javascript
var mongoose_latinize = require('mongoose-latinize');
var user = new mongoose.Schema({ first_name: String });
user.plugin(mongoose_latinize, 'first_name');
```This adds a new path to your schema, `latin_first_name`, storing the lower-case, [`latinize`d](https://www.npmjs.com/package/latenize) copy of `first_name`.
```javascript
var user1 = new user({ first_name : 'Björk' });
user1.save(function(err, doc) {
console.log(doc.latin_first_name); // returns 'bjork'
});
```### options
You can pass a simple string containing the property name (as above), or an object, with the following
- `prop` - string, required - the data source for the `latin_`-prefixed property
- `index` - bool, defaults `true` - creates index on the `latin_`-prefixed property
- `json` - bool, defaults `false` - include the latinized property when calling `.toJSON()`For example, to not use an index and to include the properties in JSON transforms:
```javascript
var user = new mongoose.Schema({ first_name: String });user.plugin(mongoose_latinize, {
prop: 'first_name',
index: false,
json: true
});
```