TONY0922のブログ

学んだことを適当に記録していくブログです。主にRuby, Java, PHPで仕事してます。更新頻度はそんなに高くないので、ご了承下さい。

Titanium Mobile にて 特定のテーブルのレコードを全消去する

Titanium SDK:3.2.0
Alloy:1.3.0

Truncateがなかったので、パフォーマンスがアレですが、
下記でテーブルのレコードが全部、消せます。

var collection = Alloy.createCollection('model_name');
collection.fetch();
while (collection.length) {
	collection.at(0).destroy();
}

ここを参考にしました。

https://developer.appcelerator.com/question/148160/destroy-model-in-alloy-doesnt-seem-to-be-working