Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I remove specific value from persist? #44

Open
changdongchun opened this issue Oct 19, 2020 · 11 comments
Open

How can I remove specific value from persist? #44

changdongchun opened this issue Oct 19, 2020 · 11 comments
Assignees
Labels

Comments

@changdongchun
Copy link

get,set 말고 저장된 값중 잘못 저장된 값을 지울 수 있을까요?
혹은 set을 통해 특정값을 날릴 수 가 있을지... 문의 드려 봅니다.

@WoodNeck
Copy link
Member

WoodNeck commented Oct 19, 2020

Hello, @changdongchun!
You can try persist.set("key", null);


특정 값 삭제는 위와 같이 null 지정을 통해 가능합니다.

@WoodNeck WoodNeck self-assigned this Oct 19, 2020
@WoodNeck WoodNeck changed the title 저장한 특정 값을 지우는 기능이 있을까요? How can I remove specific value from persist? Oct 19, 2020
@changdongchun
Copy link
Author

현재
welcomePersist.set("currentPanel_element", persistObj);
위와 같이 키값은 "currentPanel_element"하나이고 그안에 오브젝트들 형태로 값들을 넣고 있는데요
이 오브젝트내 특정 값을 지울 수는 없을까요?

@WoodNeck
Copy link
Member

오브젝트 저장시에는 해당 오브젝트의 레퍼런스를 저장하고 있는 것이므로,
get 이후에 오브젝트 내의 키를 직접적으로 삭제하시면 될 것 같습니다. (delete 이용 혹은 값 덮어쓰기)
잘 안되신다면 get 이후 값 조정하신 이후 set하시면 될 것 같습니다.

@daybrush
Copy link
Member

daybrush commented Oct 19, 2020

@changdongchun

안녕하세요.

persist.set("key.subkey.subkey", undefined);

을 하시면 object의 특정 키를 지우실 수 있습니다.

@changdongchun
Copy link
Author

changdongchun commented Oct 19, 2020

우선

function delObjPersist(areaId)
{
    var persistObj = getBrowserHistory();
    var arrFlickSettings = [];
    if (typeof (persistObj.flickSetting) != "undefined") {
        arrFlickSettings = persistObj.flickSetting;
    }

    $.each(arrFlickSettings, function (i, v) {
        if (v.areaId == areaId) {
            arrFlickSettings.splice(i, 1);
            return false;
        }
    });

    persistObj.flickSetting = arrFlickSettings;
    persistObj.historyYn = "Y";
    welcomePersist.set("currentPanel_element", persistObj);
}

와 같이 get을 한다음 배열을 빼고 set을 했는데요

알려주신 방식으로도 한번 테스트 해보겠습니다. 감사합니다.

@changdongchun
Copy link
Author

알려주신대로 시도 해보았는데 값이 지워지질 않는 듯 한데요
set부분을 잘못 호출한 걸까요?
000

@daybrush
Copy link
Member

@changdongchun

죄송합니다. @WoodNeck 님이 말하신 방법으로 사용해야 할 것 같습니다.

@changdongchun
Copy link
Author

항상 감사합니다.

@daybrush
Copy link
Member

@changdongchun

혹시 null이 아닌 undefined으로 설정해보시길 바랍니다.

@changdongchun
Copy link
Author

000

null과 동일하게 값의 변화가 없습니다.

get,후 set은 정상적으로 값이 사라짐을 확인하긴 했습니다.

@daybrush
Copy link
Member

@changdongchun

아 배열의 value에 키가 있는 형태이군요. ㅠㅠ @WoodNeck 님의 코멘트처럼 하셔야되겠네요 ㅠㅠ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants