🧵find()

Example

import { Model, Schema, Types } from 'cherry3';

const schema = Schema({
name: String,
surname: Types.String,
age: Types.Number,
classNumber: Number,
achievements: { type: Array, default: [] },
closeFriends: Object
});

const model = new Model('classList',schema)

(async() => {

var result = await model.find({ age: 5 },{ $sort:{ classNumber: -1 } });
console.log(result)
/*
[
{id:1, name: 'Paul', surname: 'Grey', age: 5, classNumber: 3, achievements:[]},
{id:2, name: 'Jesse', surname: 'Clean', age: 5, classNumber: 7, achievements:["reading"]},
{id:3, name: 'Garry', surname: 'Davis', age: 5, classNumber: 8, achievements:[]},
]
*/

})();

Last updated