How to take data from last entry on firebase realtime chat


Hi all

I added chat on my project. I use firebase realtime database.

But I don’t want to take all data on database , I would like to take data from last entry like whatsapp.

how can I do this?

I take data with this code;

 messages: object[] = [];

  constructor(public navCtrl: NavController, public navParams: NavParams,public db: AngularFireDatabase,public camera:Camera,private imagePicker:ImagePicker,
    public cropService: Crop,public translate: TranslateService,private toastCtrl: ToastController) {
    this.username = this.navParams.get('username');
    this._chatSubscription = this.db.list('/'+this.navParams.get("chatid")).subscribe( data => {
      this.messages = data;

Thanks , have a nice day.